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

# Get a conversion job, with a link to download the result once it's completed

> Returns a conversion job. Read it every 1–2 seconds until `status` is `Completed` or `Failed`. A queued job waits its turn behind other conversions, so the time until `Completed` depends on how much is queued. While the job is queued, `position` says about how many jobs are ahead of it.

- `Queued`: waiting to be converted. A failed attempt that will be retried returns the job to `Queued`.
- `Running`: being converted.
- `Completed`: `result` holds a signed `url` to download the converted image. Each read signs a fresh link, valid for 1 hour.
- `Failed`: `error` says why.

A job can be read for at least a day after it finishes. Once the converted image is deleted, reading a completed job answers `404`.



## OpenAPI

````yaml /api-reference/openapi/media.json get /v1/image-conversions/jobs/{jobId}
openapi: 3.2.0
info:
  title: Media API
  description: >-
    Convert images on demand and manage the tenant's conversion presets. The
    tenant comes from the credential, never from the route or request body.


    ## The conversion flow


    1. `POST /v1/image-conversions` with the original's `filename` returns an
    `id` and a signed `uploadUrl`.

    2. `PUT` the original to `uploadUrl` with the header `x-ms-blob-type:
    BlockBlob`. The bytes go straight to Azure Blob Storage and never pass
    through Occtoo.

    3. `POST /v1/image-conversions/<id>/convert` with the conversion
    `parameters`, or with a `preset` (see [Conversion
    presets](#conversion-presets)), queues the conversion and returns a job. The
    `Location` header holds its URL.

    4. `GET /v1/image-conversions/jobs/<jobId>` every 1–2 seconds until `status`
    is `Completed`, with a signed `result.url` to download the converted image,
    or `Failed`, with an `error` that says why. A queued job waits behind other
    conversions, so how long that takes depends on how much is queued.


    The upload link is valid for 1 hour. Each read of a completed job signs a
    download link valid for 1 hour from that read. Originals and converted
    images are deleted after a day. Converting after that answers `404`, and so
    does reading the completed job.


    ## Parameters


    | Field | Rule |

    |---|---|

    | `mode` | `Fit` scales the image to fit inside the canvas, keeping its
    proportions, so one side can come out shorter. `FillBackground` fits it
    inside the canvas minus the padding and fills the rest with `background`.
    `Crop` fills the canvas and crops from the centre. `Auto` crops when the
    image and canvas share an orientation and fits otherwise. |

    | `targetSize` | The canvas's longer side in pixels, from 1 to 8000. |

    | `aspectRatio` | The canvas as `width:height`, each side a whole number
    from 1 to 100, for example `1:1` or `4:3`. |

    | `paddingPercent` | Padding on each side as a percentage of `targetSize`,
    from 0 to 49. Required with `FillBackground` and not allowed with any other
    mode. The canvas minus the padding on both sides must be at least 1 px. |

    | `background` | Optional. The colour behind transparent areas and padding,
    as six hex digits without `#`, for example `FFFFFF`. |

    | `outputFormat` | `Jpg`, `Png` or `Webp`. |

    | `quality` | From 1 to 100. |


    `mode` and `outputFormat` are case-insensitive strings; numbers aren't
    accepted.


    ## Conversion presets


    A preset stores `parameters` under an `id` so you can reuse them by name.
    `/v1/conversion-presets` lists, gets, creates, replaces and deletes presets.
    To convert with a preset, send its `id` as `preset` to the convert endpoint
    in place of `parameters`. The conversion uses the preset's current
    `parameters`.


    - `id`: a lower-case letter, then lower-case letters, digits, `_` or `-`, at
    most 64 characters. It can't be changed.

    - `displayName`: 2–50 printable ASCII characters, with no leading or
    trailing space.

    - `parameters`: the same fields and rules as above. An unset
    `paddingPercent` or `background` is returned as `null`.

    - `version`: 1 when created. Goes up by one when `parameters` change or a
    deleted preset is created again. Changing only `displayName` keeps it.


    The list is ordered by `id` and comes back one page at a time as `items`,
    `after` and `totalCount`. `limit` sets the page size, from 1 to 200, default
    50. Pass a page's `after` as the `after` parameter to get the next page.
    It's `null` on the last page. `totalCount` is `null` unless you set
    `includeTotalCount=true`.


    ## 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`. Listing and getting presets need the `read:media` permission.
    Creating, replacing and deleting presets, and the conversion endpoints, need
    `write:media`.


    ## Responses


    Successful responses return the resource directly. Requesting a conversion
    and creating a preset answer `201`, converting answers `202`, deleting a
    preset answers `204`, and everything else answers `200`. A conversion that
    fails isn't an error response: reading its job answers `200` with `status`
    `Failed` and an `error`.


    | Status | When |

    |---|---|

    | `400` | An invalid `filename`; neither or both of `preset` and
    `parameters`, or invalid `parameters`; an original of `maxFileSize` bytes or
    more; an invalid preset `id`, `displayName` or `parameters`; a list `limit`
    out of range, an `after` the list didn't return, or a `before` or `offset`
    parameter. |

    | `401` | No credential, or an invalid one. |

    | `403` | A credential without the operation's permission. |

    | `404` | An unknown `id`, another tenant's `id`, nothing uploaded yet, or
    an original that was already deleted; an unknown or deleted preset; an
    unknown job, or a completed job whose result is no longer kept. |

    | `409` | Creating a preset whose `id` is in use; deleting a preset whose
    conversion property a card definition binds on a source. |

    | `500` | Anything else. |


    Errors use ProblemDetails (RFC 9457) with the `application/problem+json`
    content type. A validation `400` lists each invalid field under `errors`,
    for example `Parameters.TargetSize`, or `Preset` when a convert sends
    neither or both of `preset` and `parameters`. A body that isn't valid JSON,
    misses a required field, or has a value of the wrong type, an unknown enum
    name, or an `aspectRatio` or `background` in the wrong format, answers `400`
    without `errors`. Retry `500` with bounded exponential backoff. A convert
    that answered `500` may have queued the conversion anyway, so a retry can
    queue a second one.


    Machine-readable contract:
    [OpenAPI](https://api.occtoo.com/openapi/media.json)
  version: 1.0.0
  summary: >-
    Convert images on demand and manage conversion presets (named, reusable
    conversion parameters).
servers:
  - url: https://api.occtoo.com
    description: Occtoo public API
security: []
tags:
  - name: Conversion presets
  - name: Image conversions
paths:
  /v1/image-conversions/jobs/{jobId}:
    get:
      tags:
        - Image conversions
      summary: >-
        Get a conversion job, with a link to download the result once it's
        completed
      description: >-
        Returns a conversion job. Read it every 1–2 seconds until `status` is
        `Completed` or `Failed`. A queued job waits its turn behind other
        conversions, so the time until `Completed` depends on how much is
        queued. While the job is queued, `position` says about how many jobs are
        ahead of it.


        - `Queued`: waiting to be converted. A failed attempt that will be
        retried returns the job to `Queued`.

        - `Running`: being converted.

        - `Completed`: `result` holds a signed `url` to download the converted
        image. Each read signs a fresh link, valid for 1 hour.

        - `Failed`: `error` says why.


        A job can be read for at least a day after it finishes. Once the
        converted image is deleted, reading a completed job answers `404`.
      operationId: getImageConversionJob
      parameters:
        - name: jobId
          in: path
          description: The job's `id`, returned by the convert endpoint.
          required: true
          schema:
            type: string
            format: uuid
          example: 0193a5c4-7e1f-7b2a-9c3d-4e5f60718293
      responses:
        '200':
          description: The job.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ImageConversionJob'
              examples:
                queued:
                  summary: A queued conversion
                  value:
                    id: 0193a5c4-7e1f-7b2a-9c3d-4e5f60718293
                    status: Queued
                    position: 12
                    queuedAt: '2026-11-29T10:14:03.512417+00:00'
                    result: null
                    error: null
                completed:
                  summary: A completed conversion with a link to download the result
                  value:
                    id: 0193a5c4-7e1f-7b2a-9c3d-4e5f60718293
                    status: Completed
                    position: null
                    queuedAt: '2026-11-29T10:14:03.512417+00:00'
                    result:
                      url: >-
                        https://occtoomedia.blob.core.windows.net/conversion-scratch/6b1f0b3c-6f2e-4a52-9a1e-7c6f0c2f9a10/3f9d2c1e-8b4a-4e6f-9a7d-1c2b3d4e5f60/9c2a7d18-4f6b-4f0b-9a2a-2f2e6c7d8e90/shoe.jpg?sv=2024-11-04&se=...&sig=...
                      expiresAt: '2026-11-05T13:31:00+00:00'
                      filename: shoe.jpg
                      contentType: image/jpeg
                      size: 184320
                    error: null
                failed:
                  summary: A failed conversion
                  value:
                    id: 0193a5c4-7e1f-7b2a-9c3d-4e5f60718293
                    status: Failed
                    position: null
                    queuedAt: '2026-11-29T10:14:03.512417+00:00'
                    result: null
                    error: The uploaded file can't be converted.
        '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: Unknown `jobId`, or a completed job whose result is no longer kept.
          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:
    ImageConversionJob:
      required:
        - id
        - status
        - position
        - queuedAt
        - result
        - error
      type: object
      properties:
        id:
          type: string
          description: The job's id.
          format: uuid
        status:
          $ref: '#/components/schemas/ConversionJobStatus'
          description: The job's current status.
        position:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - 'null'
            - integer
            - string
          description: >-
            About how many queued jobs are ahead of this one. 0 means it's next,
            and 1000 means 1000 or more. It's an estimate: null when the job
            isn't queued, and sometimes null while it is.
          format: int32
        queuedAt:
          type: string
          description: >-
            When the job joined the queue. If an attempt failed and will be
            retried, it's when the job rejoins the queue, about a minute after
            the failure.
          format: date-time
        result:
          oneOf:
            - type: 'null'
            - $ref: '#/components/schemas/ConvertedImage'
              description: The converted image, once the job is completed.
        error:
          type:
            - 'null'
            - string
          description: Why the conversion failed, once the job has failed.
      description: A queued conversion of an uploaded original.
    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
    ConversionJobStatus:
      enum:
        - Queued
        - Running
        - Completed
        - Failed
      description: Where a conversion job is in its life.
    ConvertedImage:
      required:
        - url
        - expiresAt
        - filename
        - contentType
        - size
      type: object
      properties:
        url:
          type: string
          description: The link to download the converted image.
        expiresAt:
          type: string
          description: When the download link expires.
          format: date-time
        filename:
          type: string
          description: The original's name with the output format's extension.
        contentType:
          type: string
          description: The converted image's media type.
        size:
          pattern: ^-?(?:0|[1-9]\d*)$
          type:
            - integer
            - string
          description: The converted image's size in bytes.
          format: int64
      description: The result of a completed conversion job.
  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.