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

# Execute Inventory Operations

> Execute a list of Inventory Operations. A maximum list of 50 operations can be performed by a single request. There is also a limit to 300 items that can be modified/added in a single request. For example, adding a bundle with 50 items counts as 50 items modified. All operations must be done within a single inventory collection. This API has a reduced RPS compared to an individual inventory operation with Player Entities limited to 60 requests in 90 seconds.

Allowed entity token types: title, master_player_account, title_player_account

## Error codes

This operation may return the following PlayFab errors:

| Error | Code |
| --- | --- |
| DatabaseThroughputExceeded | 1113 |
| InsufficientFunds | 1059 |
| InvalidCatalogItemConfiguration | 4015 |
| ItemNotFound | 1047 |
| PreconditionFailed | 1610 |




## OpenAPI

````yaml /services/playfab/api-references/rest/economy/economy.openapi.json post /Inventory/ExecuteInventoryOperations
openapi: 3.0.0
info:
  version: '260922'
  title: PlayFab Economy API
  description: >-
    API methods for managing the catalog. Inventory manages in-game assets for
    any given entity. API methods for managing the versioned catalogs.
  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: Catalog
    description: |-
      Catalog Management APIs. In general for Catalog APIs, 
                          Read APIs are limited to 100 requests in 60 seconds 
                          for Player Entities while Title Entities are limited to 10000 requests
                          in 10 seconds. For Write APIs, Player Entities are limited to 10 requests 
                          in 30 seconds and Title Entities are limited to 1000 requests in 10 seconds.
  - name: Inventory
    description: |-
      Player Inventory Management APIs. Inventory operations work on an 
                          eventually consistent system against a cache of the Catalog. It can take a few moments for 
                          changes to propagate. In general for Inventory APIs, Read APIs are limited to 100 requests 
                          in 60 seconds for Player Entities while Title Entities are limited to 10000 requests
                          in 10 seconds. For Write APIs, Player Entities are limited to 30 requests 
                          in 90 seconds and Title Entities are limited to 1000 requests in 10 seconds.
  - name: VersionedCatalog
    description: ''
paths:
  /Inventory/ExecuteInventoryOperations:
    post:
      tags:
        - Inventory
      summary: Execute Inventory Operations
      description: >
        Execute a list of Inventory Operations. A maximum list of 50 operations
        can be performed by a single request. There is also a limit to 300 items
        that can be modified/added in a single request. For example, adding a
        bundle with 50 items counts as 50 items modified. All operations must be
        done within a single inventory collection. This API has a reduced RPS
        compared to an individual inventory operation with Player Entities
        limited to 60 requests in 90 seconds.


        Allowed entity token types: title, master_player_account,
        title_player_account


        ## Error codes


        This operation may return the following PlayFab errors:


        | Error | Code |

        | --- | --- |

        | DatabaseThroughputExceeded | 1113 |

        | InsufficientFunds | 1059 |

        | InvalidCatalogItemConfiguration | 4015 |

        | ItemNotFound | 1047 |

        | PreconditionFailed | 1610 |
      operationId: ExecuteInventoryOperations
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ExecuteInventoryOperationsRequest'
        description: Execute a list of Inventory Operations for an Entity
      responses:
        '200':
          $ref: '#/components/responses/ExecuteInventoryOperationsResponse'
        '400':
          $ref: '#/components/responses/ApiErrorWrapper'
      security:
        - EntityToken: []
components:
  schemas:
    ExecuteInventoryOperationsRequest:
      description: Execute a list of Inventory Operations for an Entity
      type: object
      properties:
        CollectionId:
          description: >-
            The id of the entity's collection to perform this action on.
            (Default="default"). The number of inventory collections is
            unlimited.
          type: string
        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.
        ETag:
          description: >-
            ETags are used for concurrency checking when updating resources.
            More information about using ETags can be found here:
            https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/catalog/etags
          type: string
        IdempotencyId:
          description: >-
            The Idempotency ID for this request. Idempotency IDs can be used to
            prevent operation replay in the medium term but will be garbage
            collected eventually.
          type: string
        Operations:
          description: >-
            The operations to run transactionally. The operations will be
            executed in-order sequentially and will succeed or fail as a batch.
            Up to 50 operations can be added.
          type: array
          items:
            $ref: '#/components/schemas/InventoryOperation'
          x-isclass: true
      example:
        Operations:
          - Add:
              Item:
                Id: 11111111-1111-1111-1111-111111111111
              Amount: 3
          - Subtract:
              Item:
                Id: 11111111-1111-1111-1111-111111111111
              Amount: 3
    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
    InventoryOperation:
      type: object
      properties:
        Add:
          allOf:
            - $ref: '#/components/schemas/AddInventoryItemsOperation'
          description: The add operation.
        Delete:
          allOf:
            - $ref: '#/components/schemas/DeleteInventoryItemsOperation'
          description: The delete operation.
        Purchase:
          allOf:
            - $ref: '#/components/schemas/PurchaseInventoryItemsOperation'
          description: The purchase operation.
        Subtract:
          allOf:
            - $ref: '#/components/schemas/SubtractInventoryItemsOperation'
          description: The subtract operation.
        Transfer:
          allOf:
            - $ref: '#/components/schemas/TransferInventoryItemsOperation'
          description: The transfer operation.
        Update:
          allOf:
            - $ref: '#/components/schemas/UpdateInventoryItemsOperation'
          description: The update operation.
    ExecuteInventoryOperationsResponse:
      type: object
      properties:
        ETag:
          description: >-
            ETags are used for concurrency checking when updating resources.
            More information about using ETags can be found here:
            https://learn.microsoft.com/en-us/gaming/playfab/features/economy-v2/catalog/etags
          type: string
        IdempotencyId:
          description: The idempotency id used in the request.
          type: string
        TransactionIds:
          description: >-
            The ids of the transactions that occurred as a result of the
            request.
          type: array
          items:
            type: string
      example:
        IdempotencyId: idempotencyId
        TransactionIds:
          - transactionId1
          - transactionId2
    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
    AddInventoryItemsOperation:
      type: object
      properties:
        Amount:
          description: The amount to add to the current item amount.
          type: number
          x-actualtype: int32
        DurationInSeconds:
          description: The duration to add to the current item expiration date.
          type: number
          x-actualtype: double
        Item:
          allOf:
            - $ref: '#/components/schemas/InventoryItemReference'
          description: The inventory item the operation applies to.
        NewStackValues:
          allOf:
            - $ref: '#/components/schemas/InitialValues'
          description: The values to apply to a stack newly created by this operation.
    DeleteInventoryItemsOperation:
      type: object
      properties:
        Item:
          allOf:
            - $ref: '#/components/schemas/InventoryItemReference'
          description: The inventory item the operation applies to.
    PurchaseInventoryItemsOperation:
      type: object
      properties:
        Amount:
          description: The amount to purchase.
          type: number
          x-actualtype: int32
        DeleteEmptyStacks:
          description: >-
            Indicates whether stacks reduced to an amount of 0 during the
            operation should be deleted from the inventory. (Default = false)
          type: boolean
        DurationInSeconds:
          description: The duration to purchase.
          type: number
          x-actualtype: double
        Item:
          allOf:
            - $ref: '#/components/schemas/InventoryItemReference'
          description: The inventory item the operation applies to.
        NewStackValues:
          allOf:
            - $ref: '#/components/schemas/InitialValues'
          description: The values to apply to a stack newly created by this operation.
        PriceAmounts:
          description: >-
            The per-item price the item is expected to be purchased at. This
            must match a value configured in the Catalog or specified Store.
          type: array
          items:
            $ref: '#/components/schemas/PurchasePriceAmount'
          x-isclass: true
        StoreId:
          description: The id of the Store to purchase the item from.
          type: string
      required:
        - DeleteEmptyStacks
    SubtractInventoryItemsOperation:
      type: object
      properties:
        Amount:
          description: The amount to subtract from the current item amount.
          type: number
          x-actualtype: int32
        DeleteEmptyStacks:
          description: >-
            Indicates whether stacks reduced to an amount of 0 during the
            request should be deleted from the inventory. (Default = false).
          type: boolean
        DurationInSeconds:
          description: The duration to subtract from the current item expiration date.
          type: number
          x-actualtype: double
        Item:
          allOf:
            - $ref: '#/components/schemas/InventoryItemReference'
          description: The inventory item the operation applies to.
      required:
        - DeleteEmptyStacks
    TransferInventoryItemsOperation:
      type: object
      properties:
        Amount:
          description: The amount to transfer.
          type: number
          x-actualtype: int32
        DeleteEmptyStacks:
          description: >-
            Indicates whether stacks reduced to an amount of 0 during the
            operation should be deleted from the inventory. (Default = false)
          type: boolean
        GivingItem:
          allOf:
            - $ref: '#/components/schemas/InventoryItemReference'
          description: The inventory item the operation is transferring from.
        NewStackValues:
          allOf:
            - $ref: '#/components/schemas/InitialValues'
          description: The values to apply to a stack newly created by this operation.
        ReceivingItem:
          allOf:
            - $ref: '#/components/schemas/InventoryItemReference'
          description: The inventory item the operation is transferring to.
      required:
        - DeleteEmptyStacks
    UpdateInventoryItemsOperation:
      type: object
      properties:
        Item:
          allOf:
            - $ref: '#/components/schemas/InventoryItem'
          description: The inventory item to update with the specified values.
    InventoryItemReference:
      type: object
      properties:
        AlternateId:
          allOf:
            - $ref: '#/components/schemas/AlternateId'
          description: The inventory item alternate id the request applies to.
        Id:
          description: The inventory item id the request applies to.
          type: string
        StackId:
          description: >-
            The inventory stack id the request should redeem to.
            (Default="default")
          type: string
    InitialValues:
      type: object
      properties:
        DisplayProperties:
          description: >-
            Game specific properties for display purposes. The Display
            Properties field has a 1000 byte limit.
          type: object
    PurchasePriceAmount:
      type: object
      properties:
        Amount:
          description: The amount of the inventory item to use in the purchase .
          type: number
          x-actualtype: int32
        ItemId:
          description: The inventory item id to use in the purchase .
          type: string
        StackId:
          description: >-
            The inventory stack id the to use in the purchase. Set to "default"
            by default
          type: string
      required:
        - Amount
    InventoryItem:
      type: object
      properties:
        Amount:
          description: The amount of the item.
          type: number
          x-actualtype: int32
        DisplayProperties:
          description: >-
            Game specific properties for display purposes. This is an arbitrary
            JSON blob. The Display Properties field has a 1000 byte limit.
          type: object
        ExpirationDate:
          description: >-
            Only used for subscriptions. The date of when the item will expire
            in UTC.
          type: string
        Id:
          description: >-
            The id of the item. This should correspond to the item id in the
            catalog.
          type: string
        StackId:
          description: The stack id of the item.
          type: string
        StartDate:
          description: >-
            Only used for subscriptions. The date of when the item started in
            UTC.
          type: string
        Type:
          description: >-
            The type of the item. This should correspond to the item type in the
            catalog.
          type: string
    AlternateId:
      type: object
      properties:
        Type:
          description: Type of the alternate ID.
          type: string
        Value:
          description: Value of the alternate ID.
          type: string
  responses:
    ExecuteInventoryOperationsResponse:
      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/ExecuteInventoryOperationsResponse'
            example:
              code: 200
              status: OK
              data:
                IdempotencyId: idempotencyId
                TransactionIds:
                  - transactionId1
                  - transactionId2
    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

- [Execute Inventory Operations](/services/playfab/api-references/rest/economy/inventory/execute-inventory-operations.md)
- [PFInventoryExecuteInventoryOperationsRequest](/services/playfab/api-references/c/pfinventorytypes/structs/pfinventoryexecuteinventoryoperationsrequest.md)
- [PFInventoryExecuteInventoryOperationsAsync](/services/playfab/api-references/c/pfinventory/functions/pfinventoryexecuteinventoryoperationsasync.md)
- [PFInventoryExecuteInventoryOperationsResponse](/services/playfab/api-references/c/pfinventorytypes/structs/pfinventoryexecuteinventoryoperationsresponse.md)
- [PFInventoryExecuteInventoryOperationsGetResult](/services/playfab/api-references/c/pfinventory/functions/pfinventoryexecuteinventoryoperationsgetresult.md)
