> ## 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.

# Set Objects

> Sets objects on an entity's profile.

## Error codes

This operation may return the following PlayFab errors:

| Error | Code |
| --- | --- |
| InvalidJSONContent | 1200 |




## OpenAPI

````yaml /services/playfab/api-references/rest/data/data.openapi.json post /Object/SetObjects
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:
  /Object/SetObjects:
    post:
      tags:
        - Object
      summary: Set Objects
      description: |
        Sets objects on an entity's profile.

        ## Error codes

        This operation may return the following PlayFab errors:

        | Error | Code |
        | --- | --- |
        | InvalidJSONContent | 1200 |
      operationId: SetObjects
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SetObjectsRequest'
        description: >-
          Sets JSON objects on the requested entity profile. May include a
          version number to be used to perform optimistic concurrency operations
          during update. If the current version differs from the version in the
          request the request will be ignored. If no version is set on the
          request then the value will always be updated if the values differ.
          Using the version value does not guarantee a write though,
          ConcurrentEditError may still occur if multiple clients are attempting
          to update the same profile. 
      responses:
        '200':
          $ref: '#/components/responses/SetObjectsResponse'
        '400':
          $ref: '#/components/responses/ApiErrorWrapper'
      security:
        - EntityToken: []
components:
  schemas:
    SetObjectsRequest:
      description: >-
        Sets JSON objects on the requested entity profile. May include a version
        number to be used to perform optimistic concurrency operations during
        update. If the current version differs from the version in the request
        the request will be ignored. If no version is set on the request then
        the value will always be updated if the values differ. Using the version
        value does not guarantee a write though, ConcurrentEditError may still
        occur if multiple clients are attempting to update the same profile. 
      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.
        ExpectedProfileVersion:
          description: >-
            Optional field used for concurrency control. By specifying the
            previously returned ProfileVersion value from the GetObjects API or
            other APIs, you can ensure that the object update 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
        Objects:
          description: Collection of objects to set on the profile.
          type: array
          items:
            $ref: '#/components/schemas/SetObject'
          x-isclass: true
      required:
        - Objects
        - Entity
      example:
        ExpectedProfileVersion: 5
        Objects:
          - ObjectName: SaveSate
            DataObject:
              PlayerDetails:
                LastMissionSuccess: '2017-06-15T11:05:19Z'
                LastMissionFailure: '2017-06-12T11:05:19Z'
                MapPosition:
                  - 22
                  - 37.78
                IsPaidUpgrade: true
              GameSettings:
                Screen: FriendsList
                Favorites:
                  - Place 1
                  - Place 2
            SimpleStatements:
              Read:
                - Friend: true
              Write:
                - Self
        Entity:
          Id: A8140AB9109712B
          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
    SetObject:
      type: object
      properties:
        DataObject:
          description: >-
            Body of the object to be saved. If empty and DeleteObject is true
            object will be deleted if it exists, or no operation will occur if
            it does not exist. Only one of Object or EscapedDataObject fields
            may be used.
          type: object
        DeleteObject:
          description: >-
            Flag to indicate that this object should be deleted. Both DataObject
            and EscapedDataObject must not be set as well.
          type: boolean
        EscapedDataObject:
          description: >-
            Body of the object to be saved as an escaped JSON string. If empty
            and DeleteObject is true object will be deleted if it exists, or no
            operation will occur if it does not exist. Only one of DataObject or
            EscapedDataObject fields may be used.
          type: string
        ObjectName:
          description: Name of object. Restricted to a-Z, 0-9, '(', ')', '_', '-' and '.'.
          type: string
      required:
        - ObjectName
    SetObjectsResponse:
      type: object
      properties:
        ProfileVersion:
          description: New version of the entity profile.
          type: number
          x-actualtype: int32
        SetResults:
          description: New version of the entity profile.
          type: array
          items:
            $ref: '#/components/schemas/SetObjectInfo'
          x-isclass: true
      required:
        - ProfileVersion
      example:
        SetResults:
          - {}
        ProfileVersion: 5
    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
    SetObjectInfo:
      type: object
      properties:
        ObjectName:
          description: Name of the object
          type: string
        OperationReason:
          description: >-
            Optional reason to explain why the operation was the result that it
            was.
          type: string
        SetResult:
          allOf:
            - $ref: '#/components/schemas/OperationTypes'
          description: >-
            Indicates which operation was completed, either Created, Updated,
            Deleted or None.
    OperationTypes:
      type: string
      enum:
        - Created
        - Updated
        - Deleted
        - None
  responses:
    SetObjectsResponse:
      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/SetObjectsResponse'
            example:
              code: 200
              status: OK
              data:
                SetResults:
                  - {}
                ProfileVersion: 5
    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

- [Set Objects](/services/playfab/api-references/rest/data/object/set-objects.md)
- [entity_objects_set](/services/playfab/api-references/events/PlayerProfile/entity-objects-set.md)
- [PFDataSetObject](/services/playfab/api-references/c/pfdatatypes/structs/pfdatasetobject.md)
- [PFDataSetObjectsAsync](/services/playfab/api-references/c/pfdata/functions/pfdatasetobjectsasync.md)
- [PFDataSetObjectsRequest](/services/playfab/api-references/c/pfdatatypes/structs/pfdatasetobjectsrequest.md)
