Skip to content

Media Resources Endpoints

Media Resources API endpoints.


Overview

Method Endpoint Description
POST /api/v1/media-resources/heal Heal Media Resources
PATCH /api/v1/media-resources/{media_resource_id} Patch Media Resource Metadata

API Reference

Sartiq Backend Server - Media Resources 0.1.0

media-resources


PATCH /api/v1/media-resources/{media_resource_id}

Patch Media Resource Metadata

Description

Fill unset metadata fields on a media resource.

Only fields that are currently NULL on the resource will be updated. Fields that already have a value are silently skipped — no error is raised so that callers can fire-and-forget enrichment payloads.

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No
media_resource_id path string No

Request body

{
    "color_profile": null,
    "duration": null,
    "dominant_color": null,
    "width": null,
    "height": null,
    "alt_text": null,
    "caption": null
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the request body
{
    "properties": {
        "color_profile": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Color Profile"
        },
        "duration": {
            "anyOf": [
                {
                    "type": "number"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Duration"
        },
        "dominant_color": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Dominant Color"
        },
        "width": {
            "anyOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Width"
        },
        "height": {
            "anyOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Height"
        },
        "alt_text": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Alt Text"
        },
        "caption": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Caption"
        }
    },
    "type": "object",
    "title": "MediaResourceMetadataUpdate",
    "description": "Patch schema that only allows setting fields that are currently NULL.\n\nUsed by the PATCH /media-resources/{id} endpoint so that background\nworkers (image analysis, captioning, etc.) can enrich metadata without\noverwriting values that were already established."
}

Responses

{
    "id": "d24c3040-af4e-43c0-bab7-39c2becff38e",
    "resource_type": "IMAGE",
    "url": "string",
    "content_hash": "string",
    "extension": "string",
    "file_size": 0,
    "width": null,
    "height": null,
    "dominant_color": null,
    "protected": true,
    "alt_text": null,
    "caption": null,
    "color_profile": null,
    "duration": null,
    "aspect_ratio": null,
    "orientation": null,
    "created_at": "2022-04-13T15:42:05.901Z"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
        },
        "resource_type": {
            "$ref": "#/components/schemas/MediaResourceType"
        },
        "url": {
            "type": "string",
            "title": "Url"
        },
        "content_hash": {
            "type": "string",
            "title": "Content Hash"
        },
        "extension": {
            "type": "string",
            "title": "Extension"
        },
        "file_size": {
            "type": "integer",
            "title": "File Size"
        },
        "width": {
            "anyOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Width"
        },
        "height": {
            "anyOf": [
                {
                    "type": "integer"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Height"
        },
        "dominant_color": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Dominant Color"
        },
        "protected": {
            "type": "boolean",
            "title": "Protected",
            "default": false
        },
        "alt_text": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Alt Text"
        },
        "caption": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Caption"
        },
        "color_profile": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Color Profile"
        },
        "duration": {
            "anyOf": [
                {
                    "type": "number"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Duration"
        },
        "aspect_ratio": {
            "anyOf": [
                {
                    "type": "number"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Aspect Ratio"
        },
        "orientation": {
            "anyOf": [
                {
                    "type": "string"
                },
                {
                    "type": "null"
                }
            ],
            "title": "Orientation"
        },
        "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
        }
    },
    "type": "object",
    "required": [
        "id",
        "resource_type",
        "url",
        "content_hash",
        "extension",
        "file_size",
        "created_at"
    ],
    "title": "MediaResourcePublic",
    "description": "Public output schema for media resources.\n\nThe `url` field contains the full CDN URL resolved from the\ninternal `storage_key`."
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

POST /api/v1/media-resources/heal

Heal Media Resources

Description

Create missing MediaResource records from legacy URL fields.

The frontend calls this when it detects *_media: null on an entity that has a populated legacy *_url field. The endpoint reads the legacy fields, creates stub MediaResource + MediaResourceAttachment records, and returns the created resources so the frontend can use them immediately (e.g. for annotations).

Idempotent — safe to call multiple times for the same entity.

Input parameters

Parameter In Type Default Nullable Description
OAuth2PasswordBearer header string N/A No

Request body

{
    "entity_type": "PRODUCT",
    "entity_id": "6c97407f-9d1f-4dc8-a130-0ff8998b8aaa"
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the request body
{
    "properties": {
        "entity_type": {
            "$ref": "#/components/schemas/MediaEntityType"
        },
        "entity_id": {
            "type": "string",
            "format": "uuid",
            "title": "Entity Id"
        }
    },
    "type": "object",
    "required": [
        "entity_type",
        "entity_id"
    ],
    "title": "HealRequest",
    "description": "Request body for POST /media-resources/heal."
}

Responses

{
    "healed": [
        {
            "entity_type": "PRODUCT",
            "entity_id": "ecf0a279-5608-47b5-aa04-674da9c73065",
            "slot": "string",
            "media_resource": {
                "id": "8a6064e3-50db-4639-ba1e-e007537cc22f",
                "resource_type": "IMAGE",
                "url": "string",
                "content_hash": "string",
                "extension": "string",
                "file_size": 0,
                "width": null,
                "height": null,
                "dominant_color": null,
                "protected": true,
                "alt_text": null,
                "caption": null,
                "color_profile": null,
                "duration": null,
                "aspect_ratio": null,
                "orientation": null,
                "created_at": "2022-04-13T15:42:05.901Z"
            }
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "healed": {
            "items": {
                "$ref": "#/components/schemas/HealedSlot"
            },
            "type": "array",
            "title": "Healed"
        }
    },
    "type": "object",
    "required": [
        "healed"
    ],
    "title": "HealResponse",
    "description": "Response from POST /media-resources/heal."
}

{
    "detail": [
        {
            "loc": [
                null
            ],
            "msg": "string",
            "type": "string",
            "input": null,
            "ctx": {}
        }
    ]
}
⚠️ This example has been generated automatically from the schema and it is not accurate. Refer to the schema for more information.

Schema of the response body
{
    "properties": {
        "detail": {
            "items": {
                "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
        }
    },
    "type": "object",
    "title": "HTTPValidationError"
}

Schemas

HealedSlot

Name Type Description
entity_id string(uuid)
entity_type MediaEntityType
media_resource MediaResourcePublic
slot string

HealRequest

Name Type Description
entity_id string(uuid)
entity_type MediaEntityType

HealResponse

Name Type Description
healed Array<HealedSlot>

HTTPValidationError

Name Type Description
detail Array<ValidationError>

MediaEntityType

Type: string

MediaResourceMetadataUpdate

Name Type Description
alt_text
caption
color_profile
dominant_color
duration
height
width

MediaResourcePublic

Name Type Description
alt_text
aspect_ratio
caption
color_profile
content_hash string
created_at string(date-time)
dominant_color
duration
extension string
file_size integer
height
id string(uuid)
orientation
protected boolean
resource_type MediaResourceType
url string
width

MediaResourceType

Type: string

ValidationError

Name Type Description
ctx
input
loc Array<>
msg string
type string

Security schemes

Name Type Scheme Description
OAuth2PasswordBearer oauth2