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

# Create assets or replace their files, and get links to upload them to

> Creates assets or replaces the files behind them, and returns one signed upload link per entry key. At most 25 assets per call. The request is the same as initialize's; sending it twice ends in the same state.

| Entry key | What happens |
|---|---|
| No asset yet | Created the same way initialize creates it, in `folderId` or the data source's root folder. |
| Asset with a file | The file is deleted before the call returns. The entry goes back to `Initialized`, file details cleared, folder and other properties kept. |
| Asset still waiting for its upload | Nothing to delete. Entry reset the same way. |

`properties` follow initialize's rules: on an existing asset, a sent property is set, `null` clears it (for a localized property, that row's language), and an omitted property keeps its value.

Everything is checked before any file is deleted: properties, data source, and `folderId`, validated even when no key gets created. One bad asset fails the whole call. `PUT` the new bytes to each link and call `/complete`, as after initializing.



## OpenAPI

````yaml /api-reference/openapi/assets.json put /v1/assets/{dataSourceId}
openapi: 3.2.0
info:
  title: Assets API
  description: >-
    Upload files into an Occtoo data source. Tenant identity comes from the
    credential, never from the route or request body.


    ## The upload flow


    1. `POST /v1/assets/<dataSourceId>` registers the assets and returns a
    signed upload link per entry key.

    2. `PUT` each file to its link. The bytes go straight to Azure Blob Storage
    and never pass through Occtoo.

    3. `POST /v1/assets/<dataSourceId>/complete` confirms the uploads and
    creates the files.


    Everything is keyed by entry key. `GET` reads asset state, `DELETE` removes
    assets and the files behind them, `PUT` creates assets or replaces their
    files, and `/uploadLinks` re-signs a link that expired before the `PUT`
    happened.


    ## Authentication and access


    Select **Authorize** to reuse the existing Occtoo browser session, provide a
    tenant-scoped bearer token, or send an organization API key through
    `x-api-key`. Every operation accepts any one of `write:media`,
    `write:sources` or the established `import-datasource` permission.


    ## Batch ceilings


    - 100 assets per initialize call.

    - 25 assets per `PUT` call.

    - 50 assets per `/uploadLinks`, `/complete`, `GET` and `DELETE` call.

    - Entry keys must be unique within a request, compared case-insensitively,
    and allow letters, digits, `_` and `-`.


    ## Responses


    Successful responses return resource data directly. `DELETE` answers `204`
    with no body. The batch operations answer `200` with the keys that succeeded
    and a `failed` map of entry key to reason, so one bad asset doesn't sink the
    call.


    Errors use ProblemDetails (RFC 9457) with the `application/problem+json`
    content type. A `400` carries per-property failures under `errors`. Retry
    `429` and transient `5xx` responses with bounded exponential backoff,
    honouring `Retry-After` where present.


    Machine-readable contract:
    [OpenAPI](https://api.occtoo.com/openapi/assets.json)
  version: 1.0.0
  summary: Upload files into a data source and read the state of what was uploaded.
servers:
  - url: https://api.occtoo.com
    description: Occtoo public API
security: []
tags:
  - name: Assets
paths:
  /v1/assets/{dataSourceId}:
    put:
      tags:
        - Assets
      summary: Create assets or replace their files, and get links to upload them to
      description: >-
        Creates assets or replaces the files behind them, and returns one signed
        upload link per entry key. At most 25 assets per call. The request is
        the same as initialize's; sending it twice ends in the same state.


        | Entry key | What happens |

        |---|---|

        | No asset yet | Created the same way initialize creates it, in
        `folderId` or the data source's root folder. |

        | Asset with a file | The file is deleted before the call returns. The
        entry goes back to `Initialized`, file details cleared, folder and other
        properties kept. |

        | Asset still waiting for its upload | Nothing to delete. Entry reset
        the same way. |


        `properties` follow initialize's rules: on an existing asset, a sent
        property is set, `null` clears it (for a localized property, that row's
        language), and an omitted property keeps its value.


        Everything is checked before any file is deleted: properties, data
        source, and `folderId`, validated even when no key gets created. One bad
        asset fails the whole call. `PUT` the new bytes to each link and call
        `/complete`, as after initializing.
      operationId: putAssets
      parameters:
        - name: dataSourceId
          in: path
          description: Stable customer-facing source id within the authenticated tenant.
          required: true
          schema:
            minLength: 1
            type: string
            example: product-images
          example: product-images
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/InitializeAssetsRequest'
            examples:
              example:
                summary: Replace one asset's file and properties, create another
                value:
                  assets:
                    - entryKey: sku-1
                      filename: front-v2.jpg
                      properties:
                        - id: width
                          value: 1280
                        - id: title
                          language: sv
                          value: null
                    - entryKey: sku-3
                      filename: side.jpg
        required: true
      responses:
        '200':
          description: One upload link per entry key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InitializedAssets'
              examples:
                example:
                  summary: One link per entry key
                  value:
                    initialized:
                      sku-1:
                        uploadUrl: >-
                          https://occtoomedia.blob.core.windows.net/6b1f0b3c/9c2a7d18/front.jpg?sv=2024-11-04&se=...&sig=...
                        expiresAt: '2026-09-25T13:30:00+00:00'
                      sku-2:
                        uploadUrl: >-
                          https://occtoomedia.blob.core.windows.net/6b1f0b3c/1e77a904/back.jpg?sv=2024-11-04&se=...&sig=...
                        expiresAt: '2026-09-25T13:30:00+00:00'
                    failed: {}
        '400':
          description: Bad Request
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/HttpValidationProblemDetails'
        '401':
          description: Unauthorized
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '403':
          description: Forbidden
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '404':
          description: Not Found
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '409':
          description: Conflict
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '429':
          description: Too Many Requests
          headers:
            Retry-After:
              description: Optional number of seconds to wait before retrying.
              schema:
                minimum: 1
                type: integer
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
        '500':
          description: Internal Server Error
          content:
            application/problem+json:
              schema:
                $ref: '#/components/schemas/ProblemDetails'
      security:
        - kindeOAuth: []
        - bearerAuth: []
        - apiKey: []
components:
  schemas:
    InitializeAssetsRequest:
      required:
        - folderId
        - assets
      type: object
      properties:
        folderId:
          type:
            - 'null'
            - string
          format: uuid
        assets:
          type: array
          items:
            $ref: '#/components/schemas/NewAsset'
    InitializedAssets:
      required:
        - initialized
        - failed
      type: object
      properties:
        initialized:
          type: object
          additionalProperties:
            $ref: '#/components/schemas/AssetInitialization'
        failed:
          type: object
          additionalProperties:
            type: string
    HttpValidationProblemDetails:
      type: object
      properties:
        type:
          type:
            - 'null'
            - string
        title:
          type:
            - 'null'
            - string
        status:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - 'null'
            - integer
            - string
          format: int32
        detail:
          type:
            - 'null'
            - string
        instance:
          type:
            - 'null'
            - string
        errors:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
    ProblemDetails:
      type: object
      properties:
        type:
          type:
            - 'null'
            - string
        title:
          type:
            - 'null'
            - string
        status:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - 'null'
            - integer
            - string
          format: int32
        detail:
          type:
            - 'null'
            - string
        instance:
          type:
            - 'null'
            - string
    NewAsset:
      required:
        - entryKey
        - filename
      type: object
      properties:
        entryKey:
          type: string
        filename:
          type: string
        properties:
          type:
            - 'null'
            - array
          items:
            $ref: '#/components/schemas/TypedPropertyImport'
    AssetInitialization:
      required:
        - uploadUrl
        - expiresAt
      type: object
      properties:
        uploadUrl:
          type: string
        expiresAt:
          type: string
          format: date-time
    TypedPropertyImport:
      required:
        - id
        - value
      type: object
      properties:
        id:
          type:
            - 'null'
            - string
        value:
          $ref: '#/components/schemas/JsonElement'
        language:
          type:
            - 'null'
            - string
    JsonElement: {}
  securitySchemes:
    kindeOAuth:
      type: oauth2
      description: >-
        Sign in with the existing Occtoo Studio identity and selected
        organization.
      flows:
        authorizationCode:
          authorizationUrl: >-
            https://auth.occtoo.com/oauth2/auth?audience=https%3A%2F%2Fapi-weu.occtoo.com
          tokenUrl: https://auth.occtoo.com/oauth2/token
          scopes:
            openid: Authenticate the user with OpenID Connect.
            profile: Read the user's basic profile.
            email: Read the user's email address.
            offline: Refresh the access token without another interactive sign-in.
          x-usePkce: SHA-256
          x-scalar-redirect-uri: https://api.occtoo.com/docs/
    bearerAuth:
      type: http
      description: >-
        Tenant-scoped Occtoo access token, including Kinde machine-to-machine
        application tokens.
      scheme: bearer
      bearerFormat: JWT
    apiKey:
      type: apiKey
      description: Occtoo organization API key.
      name: x-api-key
      in: header

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.