REST API#

The Thumbnail API defines four REST endpoints:

  • POST /v1alpha/thumbnails – triggers thumbnail generation for a source file;

  • GET /v1alpha/thumbnails – reads the thumbnails associated with a target resource;

  • POST /v1alpha/associations – records that an existing thumbnail belongs to a target resource;

  • DELETE /v1alpha/associations – removes one thumbnail’s association with a target resource.

The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this section are to be interpreted as described in RFC 2119.

Every /v1alpha endpoint requires an Authorization: Bearer <accessToken> header. An implementation MUST reject an unauthenticated request before parsing the body, so a caller without a credential does not receive a description of the expected schema. A missing, invalid, or expired token is reported as 401 Unauthorized; a valid token that is not authorized for the resource is reported as 403 Forbidden where this specification defines it. How the implementation reaches that decision — validating the token itself, or asking its storage backend — is not part of the API.

Every error response carries the same body shape:

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "<description of the problem>"
}

source is REQUIRED. error_message is REQUIRED for 400 Bad Request and 404 Not Found and SHOULD name the offending field or resource so the caller can correct the request. For 401 Unauthorized and 403 Forbidden an implementation MAY omit error_message or return a generic value such as "Unauthorized" or "Forbidden"; if it returns more, the message SHOULD NOT disclose why the credential was rejected, which component made the decision, or any text originating from a backend. An optional details field MAY carry structured detail; details SHOULD NOT be present on 401 or 403. Clients MUST NOT parse error_message; its wording is illustrative throughout this document. Error messages are truncated to 4096 characters.

POST /v1alpha/thumbnails#

POST /v1alpha/thumbnails HTTP/1.1
Authorization: Bearer <accessToken>
Content-Type: application/json

{
   "resource_address": <the source file's storage address>,
   "specifications": [
      {"image_to_image": <an image-to-image specification>},
      ...
   ]
}

This API triggers thumbnail generation for one source file. The implementation resolves the source’s resource_identity from its storage backend; callers supply only resource_address.

resource_address is REQUIRED and MUST be non-blank.

specifications is OPTIONAL. When it is absent or empty, the implementation generates one thumbnail per configured default using its configured processing defaults — identical to the event-driven flow. When it is present, every entry MUST carry a specification of a kind the implementation supports for generation; a MANUAL specification, or an entry that names no kind, is rejected because nothing is generated for a caller-produced thumbnail. At most 1000 specifications MAY be sent in one request.

An image_to_image object carries width, height, encoding_format, transform_type, crop_strategy, and the OPTIONAL quality and preserve_aspect_ratio fields described in Resources, associations, and specifications. width and height MUST be in 1..=8192. quality MUST be in 1..=100 when encoding_format is JPEG or WEBP; for lossless encodings an implementation MAY ignore quality. Omitted OPTIONAL fields resolve to the deployment’s configured defaults.

All of these checks run before the source is looked up. One invalid specification rejects the whole request and accepts nothing.

The request example:

POST /v1alpha/thumbnails HTTP/1.1
Authorization: Bearer <access-token>
Content-Type: application/json

{
   "resource_address": "https://account.blob.core.windows.net/container/photos/image.jpg",
   "specifications": [
      {
         "image_to_image": {
            "width": 256,
            "height": 256,
            "encoding_format": "PNG",
            "transform_type": "FIT",
            "crop_strategy": "CENTER",
            "preserve_aspect_ratio": true
         }
      },
      {
         "image_to_image": {
            "width": 1024,
            "height": 768,
            "encoding_format": "JPEG",
            "transform_type": "SCALE_AND_CROP",
            "crop_strategy": "SMART",
            "quality": 90
         }
      }
   ]
}

The specifications field MAY be omitted to generate every configured size:

POST /v1alpha/thumbnails HTTP/1.1
Authorization: Bearer <access-token>
Content-Type: application/json

{
   "resource_address": "https://account.blob.core.windows.net/container/photos/image.jpg"
}

An implementation MAY complete generation synchronously or accept work for later processing. Both completion modes return 202 Accepted for full or partial success. In asynchronous mode, success means the specification was accepted for later processing. In synchronous mode, it means generation, upload, and association completed before the service answered. The mode is deployment configuration, not a request field or a difference in the response shape.

A full success contains only an empty failure list:

HTTP/1.1 202 Accepted
Content-Type: application/json

{
   "failed": []
}

For partial success the status stays 202, and failed names each unsuccessful specification in its resolved form with a human-readable reason. For example:

HTTP/1.1 202 Accepted
Content-Type: application/json

{
   "failed": [
      {
         "specification": {
            "image_to_image": {
               "width": 1024,
               "height": 768,
               "encoding_format": "JPEG",
               "transform_type": "SCALE_AND_CROP",
               "crop_strategy": "SMART",
               "quality": 90,
               "preserve_aspect_ratio": true
            }
         },
         "error_message": "thumbnail upload failed"
      }
   ]
}

There is no succeeded field; use GET /v1alpha/thumbnails to read successful thumbnail resources. In asynchronous mode a failure entry describes acceptance; in synchronous mode it describes generation or association. Do not compare the failure count with the input count: omitted/empty specifications expand to defaults. When every output fails, the service returns 502 Bad Gateway with the existing error envelope instead of a success response listing all specifications.

A lost response, timed-out write, or failed association can leave a thumbnail resource without an association; GET /v1alpha/thumbnails only finds associated thumbnails. See generation completion.

Error conditions#

Every status this endpoint can return, in one place:

Status

Meaning

202 Accepted

At least one specification accepted (asynchronous) or generated and associated (synchronous); failed lists the unsuccessful specifications

400 Bad Request

Request invalid — refused before the storage backend is contacted

401 Unauthorized

Missing/malformed token, or token rejected during the initial source lookup

403 Forbidden

Initial source lookup accepted the token but denied access to the source

404 Not Found

Initial source lookup found no resource_address

502 Bad Gateway

Initial source lookup could not complete, or every specification failed acceptance (asynchronous) or generation/association (synchronous)

After a successful source lookup, failures during synchronous execution use per-specification reporting and the total-failure rule, including a later source Read authentication or access failure.

The following error conditions are defined:

Missing, malformed, invalid, or expired credential

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "Unauthorized"
}

The credential is valid but the caller is not authorized for the source

HTTP/1.1 403 Forbidden
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "Forbidden"
}

The request is invalid — a blank resource_address, more than 1000 specifications, a specification without image_to_image, a dimension outside 1..=8192, or a JPEG/WebP quality outside 1..=100. These are refused before the storage backend is contacted.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "specification 1: quality must be between 1 and 100 for JPEG/WebP"
}

Other messages of this class: specification 0: width must be between 1 and 8192, specifications must contain at most 1000 entries, specifications[0]: only image_to_image specifications are supported for CreateThumbnails; the image_to_image field must be set, and invalid JSON body: ... for a body that does not deserialize.

The source resource_address does not exist

HTTP/1.1 404 Not Found
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "resource not found in storage"
}

The source lookup could not complete, or every specification failed acceptance (asynchronous) or generation/association (synchronous). A failed initial lookup starts no generation. A timed-out submission or write MAY still have effects; query associations before retrying, while remembering they cannot expose unassociated uploads.

HTTP/1.1 502 Bad Gateway
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "all thumbnail task submissions failed: ..."
}

Both completion modes use this error shape and status when every specification fails. A conversion failure during synchronous completion follows the same rule.

GET /v1alpha/thumbnails#

GET /v1alpha/thumbnails?association_target_resource_address=<target address>[&specification=<kind>][&width=<n>][&height=<n>][&encoding_format=<format>][&transform_type=<type>][&crop_strategy=<strategy>] HTTP/1.1
Authorization: Bearer <accessToken>

This API returns the thumbnails associated with one target resource. It is read-only.

association_target_resource_address is REQUIRED, MUST be non-blank, and MUST NOT exceed 2048 characters. Associations are keyed on the target’s address for FILE and FOLDER targets alike, so no identity is supplied or resolved.

Every other parameter is an OPTIONAL filter. A supplied filter MUST match a stored value exactly; an omitted filter does not narrow the result. specification selects the specification kind to match, named as in a specification’s type (for example IMAGE_TO_IMAGE). width and height MUST be in 1..=8192. transform_type and crop_strategy match against the stored specification only. An unknown query parameter, or a value the implementation does not support, is rejected rather than ignored.

The request example:

GET /v1alpha/thumbnails?association_target_resource_address=https%3A%2F%2Faccount.blob.core.windows.net%2Fcontainer%2Fphotos%2Fimage.jpg&encoding_format=PNG HTTP/1.1
Authorization: Bearer <access-token>

The success response returns 200 OK. Entries are ordered by the thumbnail’s resource_address and capped at 1000; a target with more thumbnails has the remainder discarded, not paginated, so a response holding exactly 1000 entries may be incomplete. Addresses and identities are reported as stored in the association metadata.

HTTP/1.1 200 OK
Content-Type: application/json

{
   "thumbnails": [
      {
         "target_type": "FILE",
         "association_target": {
            "resource_address": "https://account.blob.core.windows.net/container/photos/image.jpg",
            "resource_identity": "fileobject:src-def456:v3"
         },
         "thumbnail": {
            "resource_address": "https://account.blob.core.windows.net/container/thumbnails/8b6066de.../256x256/image.jpg.auto.png",
            "resource_identity": "fileobject:thumb-abc123:v7"
         },
         "specification": {
            "type": "IMAGE_TO_IMAGE",
            "width": 256,
            "height": 256,
            "encoding_format": "PNG",
            "transform_type": "FIT",
            "crop_strategy": "CENTER",
            "quality": 85,
            "preserve_aspect_ratio": true
         },
         "create_time": "2026-09-11T12:34:56Z"
      }
   ]
}

A target with no associations, or none matching the filters, is a successful read of nothing:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "thumbnails": []
}

A stored entry that cannot be interpreted is skipped and logged; the readable entries are still returned. A target whose every entry is unreadable therefore also answers 200 OK with an empty list.

Error conditions#

The following error conditions are defined:

Missing, malformed, invalid, or expired credential

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "Unauthorized"
}

The credential is valid but the caller is not authorized for the target

HTTP/1.1 403 Forbidden
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "Forbidden"
}

Invalid or unsupported query parameters

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "invalid query: width must be between 1 and 8192"
}

Other messages of this class: invalid query: association_target_resource_address is required, invalid query: association_target_resource_address must not exceed 2048 characters, and invalid query: ... naming an unknown parameter or an undefined enum value.

The implementation’s association store could not be read

HTTP/1.1 502 Bad Gateway
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "Storage service is unavailable"
}

POST /v1alpha/associations#

POST /v1alpha/associations HTTP/1.1
Authorization: Bearer <accessToken>
Content-Type: application/json

{
   "target_type": "FILE" | "FOLDER",
   "thumbnail": <a Resource with "resource_address" and "resource_identity">,
   "association_target": <a Resource with "resource_address" and, for FILE, "resource_identity">,
   "specification": <a flat, "type"-tagged specification>
}

This API records that an already-existing thumbnail belongs to a target resource. It does not generate anything: the caller has produced, or otherwise obtained, the thumbnail bytes and is registering the link.

thumbnail MUST carry both resource_address and resource_identity — a thumbnail is always a file.

association_target MUST carry resource_address. When target_type is FILE (the default when omitted) it MUST also carry resource_identity; when target_type is FOLDER it MUST NOT.

specification is REQUIRED and MUST be a flat, type-tagged object (see Wire shapes). type MUST be one of the specification kinds defined in Specifications, and encoding_format MUST be a value of the corresponding encoding enumeration. An implementation MUST accept every specification kind the type system defines, regardless of which kinds it can itself generate: recording an association for a thumbnail the caller already produced needs no conversion capability. A type or encoding_format the type system does not define MUST be rejected with 400 Bad Request naming the field, before anything is recorded.

width and height MUST be in 1..=8192. For lossy encodings (JPEG, WEBP) quality, when present, MUST be in 1..=100; for lossless encodings an implementation MAY ignore quality. Omitted OPTIONAL fields of an IMAGE_TO_IMAGE specification resolve to the implementation’s configured defaults before the association is recorded. A null quality is equivalent to omitting it.

The request example:

POST /v1alpha/associations HTTP/1.1
Authorization: Bearer <access-token>
Content-Type: application/json

{
   "target_type": "FILE",
   "thumbnail": {
      "resource_address": "https://account.blob.core.windows.net/container/.thumbs/image-256.png",
      "resource_identity": "fileobject:thumb-abc123:v7"
   },
   "association_target": {
      "resource_address": "https://account.blob.core.windows.net/container/photos/image.jpg",
      "resource_identity": "fileobject:src-def456:v3"
   },
   "specification": {
      "type": "IMAGE_TO_IMAGE",
      "width": 256,
      "height": 256,
      "encoding_format": "PNG",
      "transform_type": "FIT",
      "crop_strategy": "CENTER",
      "quality": 85,
      "preserve_aspect_ratio": true
   }
}

Registering a pre-generated thumbnail on a folder:

POST /v1alpha/associations HTTP/1.1
Authorization: Bearer <access-token>
Content-Type: application/json

{
   "target_type": "FOLDER",
   "thumbnail": {
      "resource_address": "https://account.blob.core.windows.net/container/projects/.folder-preview.png",
      "resource_identity": "fileobject:thumb-folder-9:v1"
   },
   "association_target": {
      "resource_address": "https://account.blob.core.windows.net/container/projects/"
   },
   "specification": {
      "type": "MANUAL",
      "width": 512,
      "height": 512,
      "encoding_format": "PNG"
   }
}

The success response returns 204 No Content with an empty body. Callers MUST treat any 2xx status as success rather than matching 200. The stored association — including the resolved specification and its deterministic key — is readable through GET /v1alpha/thumbnails. Associating the same thumbnail with the same target and specification again overwrites the same entry.

HTTP/1.1 204 No Content

An implementation MAY publish a change notification once the association is recorded. If it does, the notification MUST NOT be emitted before the association is readable through GET /v1alpha/thumbnails, and publication MUST NOT affect the response: 204 No Content is returned whether or not a notification was delivered. Delivery is best-effort — a notification MAY be lost — so consumers MUST NOT rely on it as the only signal that an association exists; the read API is authoritative.

Error conditions#

The following error conditions are defined:

Missing, malformed, invalid, or expired credential

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "Unauthorized"
}

The request is invalid — malformed JSON, a missing or blank address, a file without an identity, a folder with an identity, a missing specification, or a value outside its range. Nothing is written.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "invalid association_target resource: resource_identity is required for file resources"
}

Other messages of this class: specification is required, invalid thumbnail resource: resource_address is required and non-empty, invalid association_target resource: resource_identity must be omitted for folder resources, specification width and height must both be between 1 and 8192, specification quality must be between 1 and 100 for JPEG/WebP, and invalid JSON body: ....

Recording the association failed for a reason other than authentication. If recovery from a partial update succeeds and no concurrent associate or disassociate changed the same association, the previous association is restored, or the new entry is removed when no prior association existed. Recovery can overwrite a concurrent update or recreate an entry removed concurrently; a failed request does not prove that the previous state was preserved. If recovery itself fails, the message identifies both failures and the affected entry. Restore or reconcile that entry with the intended association state; deleting it may discard a valid earlier association.

HTTP/1.1 500 Internal Server Error
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "Failed to associate thumbnail: Storage service call failed: ..."
}

DELETE /v1alpha/associations#

DELETE /v1alpha/associations?association_target_resource_address=<target address>&thumbnail_resource_address=<thumbnail address>[&target_type=FILE|FOLDER][&association_target_resource_identity=<identity>][&thumbnail_resource_identity=<identity>] HTTP/1.1
Authorization: Bearer <accessToken>

This API removes one thumbnail’s association with one target resource. Other thumbnails associated with the same target are left untouched, and the thumbnail resource itself remains for its owner to manage; nothing is deleted from storage.

association_target_resource_address and thumbnail_resource_address are REQUIRED and MUST be non-blank. The target address selects the metadata collection; the thumbnail address selects every entry whose stored thumbnail.resource_address matches it. If at least one entry matches, the service MUST attempt every matching removal and report the thumbnail once: in succeeded when all removals succeed, or in failed if any removal fails. Failed removals can leave matching entries for a later retry. If no entry matches, both arrays MUST be empty.

target_type is OPTIONAL and defaults to FILE. The two identity parameters are OPTIONAL and are ignored: only addresses locate and remove entries, for FILE and FOLDER targets alike.

The request example:

DELETE /v1alpha/associations?association_target_resource_address=https%3A%2F%2Faccount.blob.core.windows.net%2Fcontainer%2Fphotos%2Fimage.jpg&thumbnail_resource_address=https%3A%2F%2Faccount.blob.core.windows.net%2Fcontainer%2F.thumbs%2Fimage-256.png HTTP/1.1
Authorization: Bearer <access-token>

The success response returns 200 OK. succeeded carries the removed thumbnail; failed is empty:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "succeeded": [
      {
         "resource_address": "https://account.blob.core.windows.net/container/.thumbs/image-256.png",
         "resource_identity": "fileobject:thumb-abc123:v7"
      }
   ],
   "failed": []
}

The operation is idempotent. When the thumbnail is not associated with the target — already removed, or never linked — the response is 200 OK with both arrays empty, never a not-found error:

HTTP/1.1 200 OK
Content-Type: application/json

{
   "succeeded": [],
   "failed": []
}

An implementation MAY publish a change notification once the association is removed. If it does, the notification MUST NOT be emitted before the removal is visible through GET /v1alpha/thumbnails, and publication MUST NOT affect the response. Delivery is best-effort — a notification MAY be lost — so consumers MUST NOT rely on it as the only signal that an association was removed; the read API is authoritative.

Error conditions#

The following error conditions are defined:

Missing, malformed, invalid, or expired credential. Nothing is removed.

HTTP/1.1 401 Unauthorized
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "Unauthorized"
}

A required address is missing or blank, or target_type is not FILE or FOLDER. Validation runs before the storage backend is contacted.

HTTP/1.1 400 Bad Request
Content-Type: application/json

{
   "source": "thumbnail-service",
   "error_message": "invalid thumbnail_resource_address: resource_address is required and non-empty"
}

The association entry was found but could not be removed. The response body is the DisassociateThumbnailResponse shape, with failed identifying the thumbnail and the backend error.

HTTP/1.1 502 Bad Gateway
Content-Type: application/json

{
   "succeeded": [],
   "failed": [
      {
         "resource_address": "https://account.blob.core.windows.net/container/.thumbs/image-256.png",
         "resource_identity": "fileobject:thumb-abc123:v7",
         "error": "failed to remove thumbnail from storage: Storage service call failed: ..."
      }
   ]
}

The association store could not be read at all. No entry was inspected; both arrays are empty.

HTTP/1.1 502 Bad Gateway
Content-Type: application/json

{
   "succeeded": [],
   "failed": []
}

OpenAPI definition#

An OpenAPI 3.1 document generated from the reference implementation is kept in the thumbnail-service repository. It describes what that implementation serves and may lag this specification.

See next#