> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Initiate File Uploads

> Initiates file uploads to an entity's profile.

## Error codes

This operation may return the following PlayFab errors:

| Error | Code |
| --- | --- |
| EntityFileOperationPending | 1350 |




## OpenAPI

````yaml /services/playfab/api-references/rest/data/data.openapi.json post /File/InitiateFileUploads
openapi: 3.0.0
info:
  version: '260922'
  title: PlayFab Data API
  description: >-
    Store arbitrary data associated with an entity. Objects are small (~1KB)
    JSON-compatible objects which are stored directly on the entity profile.
    Objects are made available for use in other PlayFab contexts, such as
    PlayStream events and CloudScript functions. Files can efficiently store
    data of any size or format. Both objects and files support a flexible
    permissions system to control read and write access by other entities.
  termsOfService: https://playfab.com/terms/
  contact:
    url: https://community.playfab.com/index.html
  license:
    name: Apache 2.0
    url: https://github.com/PlayFab/API_Specs/blob/master/LICENSE
servers:
  - url: https://{titleId}.playfabapi.com
    description: PlayFab title endpoint
    variables:
      titleId:
        default: your_title_id
        description: Your PlayFab title ID (hex).
security: []
tags:
  - name: File
    description: File Management APIs
  - name: Object
    description: Entity Object Management APIs
paths:
  /File/InitiateFileUploads:
    post:
      tags:
        - File
      summary: Initiate File Uploads
      description: |
        Initiates file uploads to an entity's profile.

        ## Error codes

        This operation may return the following PlayFab errors:

        | Error | Code |
        | --- | --- |
        | EntityFileOperationPending | 1350 |
      operationId: InitiateFileUploads
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitiateFileUploadsRequest'
        description: >-
          Returns URLs that may be used to upload the files for a profile 5
          minutes. After using the upload calls FinalizeFileUploads must be
          called to move the file status from pending to live.
      responses:
        '200':
          $ref: '#/components/responses/InitiateFileUploadsResponse'
        '400':
          $ref: '#/components/responses/ApiErrorWrapper'
      security:
        - EntityToken: []
components:
  schemas:
    InitiateFileUploadsRequest:
      description: >-
        Returns URLs that may be used to upload the files for a profile 5
        minutes. After using the upload calls FinalizeFileUploads must be called
        to move the file status from pending to live.
      type: object
      properties:
        CustomTags:
          description: >-
            The optional custom tags associated with the request (e.g. build
            number, external trace identifiers, etc.).
          type: object
        Entity:
          allOf:
            - $ref: '#/components/schemas/EntityKey'
          description: The entity to perform this action on.
        FileNames:
          description: >-
            Names of the files to be set. Restricted to a-Z, 0-9, '(', ')', '_',
            '-' and '.'
          type: array
          items:
            type: string
        ProfileVersion:
          description: >-
            Optional field used for concurrency control. By specifying the
            previously returned ProfileVersion value from the GetFiles API or
            other APIs, you can ensure that the file upload initiation is
            performed only if the profile has not been updated since you last
            loaded that version. If the profile for the same entity has been
            updated, the operation will fail with an
            EntityProfileVersionMismatch error. The conflicting update can be
            caused by any operation that modifies the entity profile, including
            SetObjects, FinalizeFileUploads, and UpdateStatistics.
          type: number
          x-actualtype: int32
      required:
        - FileNames
        - Entity
      example:
        FileNames:
          - avatar
          - game_state
        Entity:
          Id: ID
          Type: title_player_account
          TypeString: title_player_account
    EntityKey:
      description: >-
        Combined entity type and ID structure which uniquely identifies a single
        entity.
      type: object
      properties:
        Id:
          description: Unique ID of the entity.
          type: string
        Type:
          description: >-
            Entity type. See
            https://learn.microsoft.com/gaming/playfab/features/data/entities/available-built-in-entity-types
          type: string
      required:
        - Id
    InitiateFileUploadsResponse:
      type: object
      properties:
        Entity:
          allOf:
            - $ref: '#/components/schemas/EntityKey'
          description: The entity id and type.
        ProfileVersion:
          description: >-
            The current version of the profile, can be used for concurrency
            control during updates.
          type: number
          x-actualtype: int32
        UploadDetails:
          description: Collection of file names and upload urls
          type: array
          items:
            $ref: '#/components/schemas/InitiateFileUploadMetadata'
          x-isclass: true
      required:
        - ProfileVersion
      example:
        ProfileVersion: 5
        UploadDetails:
          - FileName: game_state
            UploadUrl: https://...
          - FileName: avatar
            UploadUrl: https://...
        Entity:
          Id: ID
          Type: title_player_account
          TypeString: title_player_account
    ApiErrorWrapper:
      description: The basic wrapper around every failed API response
      type: object
      properties:
        code:
          description: Numerical HTTP code
          type: integer
        status:
          description: String HTTP code
          type: string
        error:
          description: Playfab error code
          type: string
        errorCode:
          description: Numerical PlayFab error code
          type: integer
        errorMessage:
          description: Description for the PlayFab errorCode
          type: string
        errorDetails:
          description: Detailed description of individual issues with the request object
          type: object
      required:
        - code
        - errorCode
    InitiateFileUploadMetadata:
      type: object
      properties:
        FileName:
          description: Name of the file.
          type: string
        UploadUrl:
          description: Location the data should be sent to via an HTTP PUT operation.
          type: string
  responses:
    InitiateFileUploadsResponse:
      description: ''
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: integer
                description: >-
                  The Http status code. If X-ReportErrorAsSuccess header is set
                  to true, this will report the actual http error code.
              status:
                type: string
                description: The Http status code as a string.
              data:
                $ref: '#/components/schemas/InitiateFileUploadsResponse'
            example:
              code: 200
              status: OK
              data:
                ProfileVersion: 5
                UploadDetails:
                  - FileName: game_state
                    UploadUrl: https://...
                  - FileName: avatar
                    UploadUrl: https://...
                Entity:
                  Id: ID
                  Type: title_player_account
                  TypeString: title_player_account
    ApiErrorWrapper:
      description: This is the outer wrapper for all responses with errors
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiErrorWrapper'
  securitySchemes:
    EntityToken:
      type: apiKey
      in: header
      name: X-EntityToken
      description: >-
        This API requires an Entity Session Token, available from the Entity
        GetEntityToken method.

````

## Related topics

- [Initiate File Uploads](/services/playfab/api-references/rest/data/file/initiate-file-uploads.md)
- [PFDataInitiateFileUploadsAsync](/services/playfab/api-references/c/pfdata/functions/pfdatainitiatefileuploadsasync.md)
- [PFDataInitiateFileUploadsRequest](/services/playfab/api-references/c/pfdatatypes/structs/pfdatainitiatefileuploadsrequest.md)
- [PFDataInitiateFileUploadMetadata](/services/playfab/api-references/c/pfdatatypes/structs/pfdatainitiatefileuploadmetadata.md)
- [PFDataInitiateFileUploadsResponse](/services/playfab/api-references/c/pfdatatypes/structs/pfdatainitiatefileuploadsresponse.md)
