# Media

A *Media* is a resource that holds an uploaded file. Each individual file, such as an image or a document, is managed as one *Media*. Take a clothing store as an example: the product photo "Stainless Tumbler 500ml side shot" is one *Media*.

A *Media* is managed separately from *Content*. A *Content* points to a *Media* through a `Refer` type field (e.g. a product's "main photo") to use that file. In CMA, a *Media* is a sub-resource of *Space*, and its path is based on `/spaces/{spaceId}/medias`. Management operations are performed on CMA, and a published *Media* is delivered to the outside through a delivery URL.

## Resource structure {#resource-structure}

The following is the single-read response for the published *Media* "Stainless Tumbler 500ml side shot". Along with `sys` (system properties), it has `fields` (field values) and `metadata` (additional information such as tags).

```json
{
  "sys": {
    "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
    "type": "Media",
    "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
    "publish": {
      "version": 1,
      "at": "2026-06-18T10:11:46.712Z",
      "firstAt": "2026-06-18T10:11:46.712Z",
      "counter": 1,
      "by": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } }
    },
    "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
    "createdAt": "2026-06-18T10:11:46.586Z",
    "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
    "updatedAt": "2026-06-18T10:11:46.712Z",
    "version": 2,
    "status": "Published"
  },
  "fields": {
    "title": { "en-US": "Stainless Tumbler 500ml side shot" },
    "description": { "en-US": "Side product shot of the tumbler on a white background." },
    "file": {
      "en-US": {
        "fileName": "tumbler.png",
        "contentType": "image/png",
        "mimeGroups": ["Image"],
        "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
        "detail": { "size": 50847, "image": { "width": 900, "height": 900 } }
      }
    }
  },
  "metadata": { "tags": [] }
}
```

Key properties:

- `sys.id`: The unique identifier of the *Media*. It goes into `{mediaId}` in the single-read, update, delete, and publish paths.
- `fields`: The field values of the *Media*. They consist of three keys, `title`, `description`, and `file`, whose detailed shape is explained in [File structure (file)](#file-structure-file) below.
- `metadata.tags`: The list of *Tag*s attached to this *Media*. Each entry is in the `Refer<Tag>` shape, and it is an empty array `[]` if no tags are attached.

Unlike a *Content*, a *Media* has no `contentType`. Without a template that defines its field composition, every *Media* has the same `title`, `description`, and `file` structure.

## File structure (file) {#file-structure-file}

`fields` consists of three keys, `title`, `description`, and `file`, each of which is a **per-locale map**. `title` and `description` map a *Locale* key to a string value, while `file` maps a *Locale* key to a file object. As in the example above, the demo *Media* has a value under the single `en-US` key.

The `file` object of a *Media* whose processing has finished has the following keys.

| Key | Type | Description |
|---|---|---|
| `fileName` | string | The name of the uploaded file. Example: `tumbler.png`. |
| `contentType` | string | The MIME type of the file. Example: `image/png`. |
| `mimeGroups` | array | The logical-category array of the file. Example: `["Image"]`. See the value list below. |
| `url` | string | The delivery URL of the published file. |
| `detail` | object | File detail. It has `size` (in bytes) and, for an image, `image: { width, height }`. |

`mimeGroups` is the value that groups a file into logical categories. It holds one or more of the following.

`Attachment`, `Plaintext`, `Image`, `Audio`, `Video`, `RichText`, `Presentation`, `Spreadsheet`, `PdfDocument`, `Archive`, `Code`, `Markup`.

### The shape of the file object while processing {#the-shape-of-the-file-object-while-processing}

An uploaded file is not delivered right away just after the *Media* is created. While the system is processing the file, two more keys are attached to the `file` object.

- `upload`: A `Refer<Upload>` that points to the *Upload* being processed.
- `state`: The processing state. It is one of the values below.

| `state` | Meaning |
|---|---|
| `PENDING` | Waiting to be processed. |
| `PROCESSING` | Being processed. |
| `FAILED` | Processing failed. |
| No key | Processing complete. |

When processing finishes, `upload` and `state` are removed, and `url` and `detail` are filled in instead. In other words, if there is no `state` key and `url` is present, that file is ready to be delivered.

## System properties (sys) {#system-properties-sys}

Every *Media* carries common system properties in the `sys` object. `space`, `createdBy`, and `updatedBy` are in the `Refer` shape (`{ "sys": { "id", "type": "Refer", "targetType" } }`).

| Property | Type | Description |
|---|---|---|
| `id` | string | Unique resource identifier. |
| `type` | string | Resource kind. For a *Media* this is always `"Media"`. |
| `space` | Refer&lt;Space&gt; | The *Space* this *Media* belongs to. |
| `publish` | object | The publish-state pointer. See the keys below. |
| `archive` | object | Archive information. Present only while archived; otherwise the key is absent. See the keys below. |
| `createdBy` | Refer&lt;User&gt; | The user who created it. |
| `createdAt` | string (date-time) | Creation time. |
| `updatedBy` | Refer&lt;User&gt; | The user who last updated it. |
| `updatedAt` | string (date-time) | Last update time. |
| `version` | integer (≥1) | Resource version. It increases by 1 with every change such as create, update, publish, unpublish, and archive. |
| `status` | string (enum) | Publish status. One of the four below. |

Unlike a *Content*, a *Media* has no `contentType` property, because it does not follow a template.

`status` is one of the following four values.

| `status` | Meaning |
|---|---|
| `Draft` | Being authored and not yet published. |
| `Changed` | Has been published before, but later changes are not yet published. |
| `Published` | Published with no unpublished changes. |
| `Archived` | Archived. |

The `publish` object is a pointer to the publish state. While published, it has all of the following keys.

| Key | Type | Description |
|---|---|---|
| `version` | integer | The `sys.version` at the time of publishing. |
| `at` | string (date-time) | Last publish time. |
| `firstAt` | string (date-time) | First publish time. Preserved even after unpublishing. |
| `counter` | integer | Cumulative publish count. |
| `by` | Refer&lt;User&gt; | The user who last published. |

When you unpublish, `version`, `at`, and `by` are removed from `publish`, leaving only `firstAt` and `counter`. If it has never been published, `publish` is `{ "counter": 0 }`.

The `archive` object is present only while archived. While archived it has `version` (the `sys.version` at the time of archiving), `at` (the archive time), and `by` (the user who archived it); when not archived, the `archive` key itself is absent.

The `sys.version` and all the time values in the examples below are the values at the actual call time, and they differ from call to call.

## Upload and publishing lifecycle {#upload-and-publishing-lifecycle}

A *Media* is created by first uploading a file and then referencing the result.

1. Upload a file through the [Upload API](/api/reference/upload-api.md) to get one *Upload*.
2. Create a *Media* with `POST /medias`, referencing that *Upload*. Just after creation, `status` is `Draft` and the `file`'s `state` is `PENDING`.
3. When the system finishes processing the file, it **automatically changes the *Media* to `Published`.** At that point the file becomes ready to be delivered.

If you pass the `X-Weegloo-Ignore-Publish: true` header on the `POST` request, automatic publishing is skipped and it is left as `Draft`. Updates and partial updates are also **automatically published again** by default once processing finishes, and the same header can turn that off.

Update, partial update, publish, unpublish, archive, and unarchive requests must carry the current `sys.version` in the `x-weegloo-version` header. If this value is missing or does not match the current version, it is treated as a concurrent-edit conflict and the request is rejected. Create and delete requests do not carry this header. State transitions such as publish, unpublish, archive, and unarchive have no separate request body.

Archive and delete cannot be done directly from a published state. **You must unpublish first.** Trying to archive or delete a published *Media* is rejected, and the code you get back differs by operation (see [Errors](#errors)).

## Errors {#errors}

These are the codes you meet when working with a *Media*. For codes that are common to every resource, see [common errors](/api/reference/common/errors.md).

| Code | Condition |
|---|---|
| `WGL422007` | The caller tried to archive a *Media* that was not in the `Draft` state. A *Media* in a published state (`Published`/`Changed`) must be unpublished first, and a *Media* that is already `Archived` cannot be archived again. |
| `WGL422009` | The caller tried to delete a *Media* in a published state (`Published`/`Changed`) without unpublishing that *Media* first. |
| `WGL422006` | The caller tried to unpublish a *Media* that was not in a published state (`Published`/`Changed`). |
| `WGL422008` | The caller tried to unarchive a *Media* that was not `Archived`. |
| `WGL422031` | The caller tried to update or delete a *Media* whose file was still being processed. Try again after the processing finishes. |

## API {#api}

The base URL for all endpoints below is `https://cma.weegloo.com/v1`, and a Bearer token that authenticates against CMA is required in the `Authorization` header. Update, partial update, publish, unpublish, archive, and unarchive must also send the `X-Weegloo-Version` header (the current resource's `sys.version`) for optimistic concurrency control.

```api-endpoint
{
  "title": "List Media",
  "method": "GET",
  "path": "/spaces/{spaceId}/medias",
  "description": "Reads the list of Media in a Space, page by page. To narrow it to a single category, add the fields.file.{locale}.mimeGroups query. Example: fields.file.en-US.mimeGroups=Image.",
  "responseStatus": 200,
  "baseUrl": "https://cma.weegloo.com/v1",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true }
  },
  "queryParameterSchema": {
    "limit": { "type": "integer", "description": "Number of items to return per page (1-100)", "default": 15 },
    "skip": { "type": "integer", "description": "Number of items to skip", "default": 0 },
    "next": { "type": "string", "description": "Next page cursor (the value obtained from links.next in the previous response)" },
    "prev": { "type": "string", "description": "Previous page cursor (the value obtained from links.prev in the previous response)" },
    "order": { "type": "string", "description": "Sort criteria. Comma-separated for multi-level sorting (e.g. sys.createdAt,sys.id)", "default": "sys.createdAt,sys.id" },
    "select": { "type": "string", "description": "Fields to include (sys.id,sys.createdAt) or exclude (-sys.id). Do not mix include and exclude." },
    "include": { "type": "integer", "description": "Related-resource inclusion level. 0=default, 1=related resources, 2=nested relations, 3=full", "default": 0 }
  },
  "additionalQueryParams": true,
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" }
  },
  "responseExample": {
    "sys": { "type": "TotalPageResponse" },
    "limit": 15,
    "totalCount": 1,
    "items": [
      {
        "sys": {
          "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
          "type": "Media",
          "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
          "publish": { "version": 1, "at": "2026-06-18T10:11:46.712Z", "firstAt": "2026-06-18T10:11:46.712Z", "counter": 1, "by": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } } },
          "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
          "createdAt": "2026-06-18T10:11:46.586Z",
          "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
          "updatedAt": "2026-06-18T10:11:46.712Z",
          "version": 2,
          "status": "Published"
        },
        "fields": {
          "title": { "en-US": "Stainless Tumbler 500ml side shot" },
          "description": { "en-US": "Side product shot of the tumbler on a white background." },
          "file": {
            "en-US": {
              "fileName": "tumbler.png",
              "contentType": "image/png",
              "mimeGroups": ["Image"],
              "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
              "detail": { "size": 50847, "image": { "width": 900, "height": 900 } }
            }
          }
        },
        "metadata": { "tags": [] }
      }
    ],
    "links": { "self": "/v1/spaces/tcq4V2Xb/medias" }
  }
}
```

```api-endpoint
{
  "title": "Read a single Media",
  "method": "GET",
  "path": "/spaces/{spaceId}/medias/{mediaId}",
  "description": "Reads one Media by sys.id.",
  "responseStatus": 200,
  "baseUrl": "https://cma.weegloo.com/v1",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true },
    "mediaId": { "type": "string", "description": "The sys.id of the Media", "required": true }
  },
  "queryParameterSchema": {
    "include": { "type": "integer", "description": "Related-resource inclusion level. 0=default, 1=related resources, 2=nested relations, 3=full", "default": 0 }
  },
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" }
  },
  "responseExample": {
    "sys": {
      "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
      "type": "Media",
      "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
      "publish": { "version": 1, "at": "2026-06-18T10:11:46.712Z", "firstAt": "2026-06-18T10:11:46.712Z", "counter": 1, "by": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } } },
      "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "createdAt": "2026-06-18T10:11:46.586Z",
      "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "updatedAt": "2026-06-18T10:11:46.712Z",
      "version": 2,
      "status": "Published"
    },
    "fields": {
      "title": { "en-US": "Stainless Tumbler 500ml side shot" },
      "description": { "en-US": "Side product shot of the tumbler on a white background." },
      "file": {
        "en-US": {
          "fileName": "tumbler.png",
          "contentType": "image/png",
          "mimeGroups": ["Image"],
          "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
          "detail": { "size": 50847, "image": { "width": 900, "height": 900 } }
        }
      }
    },
    "metadata": { "tags": [] }
  }
}
```

```api-endpoint
{
  "title": "Create Media",
  "method": "POST",
  "path": "/spaces/{spaceId}/medias",
  "description": "Creates a new Media by referencing an uploaded Upload. Just after creation, status is Draft and the file's state is PENDING; once processing finishes, the system automatically changes it to Published. If you pass the X-Weegloo-Ignore-Publish: true header, automatic publishing is skipped and it is left as Draft.",
  "responseStatus": 201,
  "baseUrl": "https://cma.weegloo.com/v1",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true }
  },
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" },
    "X-Weegloo-Ignore-Publish": { "type": "boolean", "description": "If true, skips automatic publishing after create/update (optional)" }
  },
  "requestBodySchema": {
    "type": "object",
    "required": ["fields"],
    "properties": {
      "fields": {
        "type": "object",
        "description": "Field values of the Media. title, description, and file are each a per-locale map. Each locale object of file takes an upload reference that points to the Upload returned by the Upload API, along with fileName, contentType, and mimeGroups."
      },
      "metadata": {
        "type": "object",
        "description": "Additional information (optional)",
        "properties": {
          "tags": { "type": "array", "description": "List of Tag references (Refer<Tag>)", "items": { "type": "object" } }
        }
      }
    },
    "example": {
      "fields": {
        "title": { "en-US": "Stainless Tumbler 500ml side shot" },
        "description": { "en-US": "Side product shot of the tumbler on a white background." },
        "file": {
          "en-US": {
            "upload": { "sys": { "id": "4bgMfu7cFGYDRQn4jdqFPe7enUp01", "type": "Refer", "targetType": "Upload" } },
            "fileName": "tumbler.png",
            "contentType": "image/png",
            "mimeGroups": ["Image"]
          }
        }
      }
    }
  },
  "responseExample": {
    "sys": {
      "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
      "type": "Media",
      "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
      "publish": { "counter": 0 },
      "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "createdAt": "2026-06-18T10:11:46.586Z",
      "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "updatedAt": "2026-06-18T10:11:46.586Z",
      "version": 1,
      "status": "Draft"
    },
    "fields": {
      "title": { "en-US": "Stainless Tumbler 500ml side shot" },
      "description": { "en-US": "Side product shot of the tumbler on a white background." },
      "file": {
        "en-US": {
          "fileName": "tumbler.png",
          "contentType": "image/png",
          "mimeGroups": ["Image"],
          "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
          "upload": { "sys": { "id": "4bgMfu7cFGYDRQn4jdqFPe7enUp01", "type": "Refer", "targetType": "Upload" } },
          "state": "PENDING"
        }
      }
    },
    "metadata": { "tags": [] }
  }
}
```

```api-endpoint
{
  "title": "Update Media (full replace)",
  "method": "PUT",
  "path": "/spaces/{spaceId}/medias/{mediaId}",
  "description": "Replaces the entire Media. Since this is a full replace, all existing values must be included in the body, and any omitted field is removed. When you send file again, it must have an upload reference pointing to a new Upload for the file to be reattached. Use PATCH if you only want to edit metadata.",
  "responseStatus": 200,
  "baseUrl": "https://cma.weegloo.com/v1",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true },
    "mediaId": { "type": "string", "description": "The sys.id of the Media", "required": true }
  },
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" },
    "X-Weegloo-Version": { "type": "integer", "description": "The current resource's sys.version (optimistic concurrency control)" },
    "X-Weegloo-Ignore-Publish": { "type": "boolean", "description": "If true, skips automatic publishing after update (optional)" }
  },
  "requestBodySchema": {
    "type": "object",
    "required": ["fields"],
    "properties": {
      "fields": {
        "type": "object",
        "description": "The full set of the Media's field values. Since this is a full replace, you must also include every value you want to keep. file must have an upload reference pointing to a new Upload."
      },
      "metadata": {
        "type": "object",
        "description": "Additional information (optional)",
        "properties": {
          "tags": { "type": "array", "description": "List of Tag references (Refer<Tag>)", "items": { "type": "object" } }
        }
      }
    },
    "example": {
      "fields": {
        "title": { "en-US": "Stainless Tumbler 500ml side shot" },
        "description": { "en-US": "Side product shot of the tumbler on a white background." },
        "file": {
          "en-US": {
            "upload": { "sys": { "id": "4bgMfu7cFGYDRQn4jdqFPe7enUp02", "type": "Refer", "targetType": "Upload" } },
            "fileName": "tumbler.png",
            "contentType": "image/png",
            "mimeGroups": ["Image"]
          }
        }
      }
    }
  },
  "responseExample": {
    "sys": {
      "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
      "type": "Media",
      "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
      "publish": { "version": 1, "at": "2026-06-18T10:11:46.712Z", "firstAt": "2026-06-18T10:11:46.712Z", "counter": 1, "by": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } } },
      "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "createdAt": "2026-06-18T10:11:46.586Z",
      "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "updatedAt": "2026-06-18T10:12:05.000Z",
      "version": 8,
      "status": "Draft"
    },
    "fields": {
      "title": { "en-US": "Stainless Tumbler 500ml side shot" },
      "description": { "en-US": "Side product shot of the tumbler on a white background." },
      "file": {
        "en-US": {
          "fileName": "tumbler.png",
          "contentType": "image/png",
          "mimeGroups": ["Image"],
          "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
          "upload": { "sys": { "id": "4bgMfu7cFGYDRQn4jdqFPe7enUp02", "type": "Refer", "targetType": "Upload" } },
          "state": "PENDING"
        }
      }
    },
    "metadata": { "tags": [] }
  }
}
```

```api-endpoint
{
  "title": "Partially update Media (JSON Patch)",
  "method": "PATCH",
  "path": "/spaces/{spaceId}/medias/{mediaId}",
  "description": "Updates only part of a Media using RFC 6902 JSON Patch. You can edit metadata such as title and description without reattaching the file. By default it is automatically published again after the update, so status stays Published and the file is unchanged. The request Content-Type header must be application/json-patch+json.",
  "responseStatus": 200,
  "baseUrl": "https://cma.weegloo.com/v1",
  "requestContentType": "application/json-patch+json",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true },
    "mediaId": { "type": "string", "description": "The sys.id of the Media", "required": true }
  },
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" },
    "Content-Type": { "type": "string", "description": "application/json-patch+json (RFC 6902 JSON Patch)" },
    "X-Weegloo-Version": { "type": "integer", "description": "The current resource's sys.version (optimistic concurrency control)" },
    "X-Weegloo-Ignore-Publish": { "type": "boolean", "description": "If true, skips automatic publishing after update (optional)" }
  },
  "requestBodySchema": {
    "type": "array",
    "description": "An array of RFC 6902 JSON Patch operations (op / path / value / from). path is an RFC 6901 JSON Pointer.",
    "items": {
      "type": "object",
      "required": ["op", "path"],
      "properties": {
        "op": { "type": "string", "enum": ["add", "remove", "replace", "move", "copy", "test"], "description": "Operation kind" },
        "path": { "type": "string", "description": "Target location (JSON Pointer). Example: /fields/title/en-US" },
        "value": { "description": "The value used by add/replace/test" },
        "from": { "type": "string", "description": "The source location for move/copy" }
      }
    },
    "example": [
      { "op": "replace", "path": "/fields/title/en-US", "value": "Stainless Tumbler 500ml side shot (edited)" }
    ]
  },
  "responseExample": {
    "sys": {
      "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
      "type": "Media",
      "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
      "publish": { "version": 2, "at": "2026-06-18T10:11:46.712Z", "firstAt": "2026-06-18T10:11:46.712Z", "counter": 2, "by": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } } },
      "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "createdAt": "2026-06-18T10:11:46.586Z",
      "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "updatedAt": "2026-06-18T10:12:18.000Z",
      "version": 4,
      "status": "Published"
    },
    "fields": {
      "title": { "en-US": "Stainless Tumbler 500ml side shot (edited)" },
      "description": { "en-US": "Side product shot of the tumbler on a white background." },
      "file": {
        "en-US": {
          "fileName": "tumbler.png",
          "contentType": "image/png",
          "mimeGroups": ["Image"],
          "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
          "detail": { "size": 50847, "image": { "width": 900, "height": 900 } }
        }
      }
    },
    "metadata": { "tags": [] }
  }
}
```

```api-endpoint
{
  "title": "Delete Media",
  "method": "DELETE",
  "path": "/spaces/{spaceId}/medias/{mediaId}",
  "description": "Deletes a Media. A published Media cannot be deleted directly, so you must unpublish it first. On success it responds with 204 No Content and no response body.",
  "responseStatus": 204,
  "baseUrl": "https://cma.weegloo.com/v1",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true },
    "mediaId": { "type": "string", "description": "The sys.id of the Media", "required": true }
  },
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" }
  }
}
```

```api-endpoint
{
  "title": "Publish Media",
  "method": "PUT",
  "path": "/spaces/{spaceId}/medias/{mediaId}/publish",
  "description": "Publishes a Media to set its status to Published. There is no request body.",
  "responseStatus": 200,
  "baseUrl": "https://cma.weegloo.com/v1",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true },
    "mediaId": { "type": "string", "description": "The sys.id of the Media", "required": true }
  },
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" },
    "X-Weegloo-Version": { "type": "integer", "description": "The current resource's sys.version (optimistic concurrency control)" }
  },
  "responseExample": {
    "sys": {
      "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
      "type": "Media",
      "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
      "publish": { "version": 1, "at": "2026-06-18T10:11:46.712Z", "firstAt": "2026-06-18T10:11:46.712Z", "counter": 1, "by": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } } },
      "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "createdAt": "2026-06-18T10:11:46.586Z",
      "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "updatedAt": "2026-06-18T10:11:46.712Z",
      "version": 2,
      "status": "Published"
    },
    "fields": {
      "title": { "en-US": "Stainless Tumbler 500ml side shot" },
      "description": { "en-US": "Side product shot of the tumbler on a white background." },
      "file": {
        "en-US": {
          "fileName": "tumbler.png",
          "contentType": "image/png",
          "mimeGroups": ["Image"],
          "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
          "detail": { "size": 50847, "image": { "width": 900, "height": 900 } }
        }
      }
    },
    "metadata": { "tags": [] }
  }
}
```

```api-endpoint
{
  "title": "Unpublish Media",
  "method": "DELETE",
  "path": "/spaces/{spaceId}/medias/{mediaId}/publish",
  "description": "Unpublishes a Media to set its status to Draft and removes it from the delivery path. There is no request body. In the response's publish object, version, at, and by are removed, leaving only firstAt and counter.",
  "responseStatus": 200,
  "baseUrl": "https://cma.weegloo.com/v1",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true },
    "mediaId": { "type": "string", "description": "The sys.id of the Media", "required": true }
  },
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" },
    "X-Weegloo-Version": { "type": "integer", "description": "The current resource's sys.version (optimistic concurrency control)" }
  },
  "responseExample": {
    "sys": {
      "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
      "type": "Media",
      "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
      "publish": { "firstAt": "2026-06-18T10:11:46.712Z", "counter": 3 },
      "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "createdAt": "2026-06-18T10:11:46.586Z",
      "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "updatedAt": "2026-06-18T10:12:29.000Z",
      "version": 5,
      "status": "Draft"
    },
    "fields": {
      "title": { "en-US": "Stainless Tumbler 500ml side shot" },
      "description": { "en-US": "Side product shot of the tumbler on a white background." },
      "file": {
        "en-US": {
          "fileName": "tumbler.png",
          "contentType": "image/png",
          "mimeGroups": ["Image"],
          "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
          "detail": { "size": 50847, "image": { "width": 900, "height": 900 } }
        }
      }
    },
    "metadata": { "tags": [] }
  }
}
```

```api-endpoint
{
  "title": "Archive Media",
  "method": "PUT",
  "path": "/spaces/{spaceId}/medias/{mediaId}/archived",
  "description": "Archives a Media to set its status to Archived. A published Media cannot be archived directly, so you must unpublish it first. There is no request body.",
  "responseStatus": 200,
  "baseUrl": "https://cma.weegloo.com/v1",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true },
    "mediaId": { "type": "string", "description": "The sys.id of the Media", "required": true }
  },
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" },
    "X-Weegloo-Version": { "type": "integer", "description": "The current resource's sys.version (optimistic concurrency control)" }
  },
  "responseExample": {
    "sys": {
      "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
      "type": "Media",
      "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
      "publish": { "firstAt": "2026-06-18T10:11:46.712Z", "counter": 3 },
      "archive": { "version": 5, "at": "2026-06-18T10:12:29.703Z", "by": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } } },
      "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "createdAt": "2026-06-18T10:11:46.586Z",
      "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "updatedAt": "2026-06-18T10:12:29.703Z",
      "version": 6,
      "status": "Archived"
    },
    "fields": {
      "title": { "en-US": "Stainless Tumbler 500ml side shot" },
      "description": { "en-US": "Side product shot of the tumbler on a white background." },
      "file": {
        "en-US": {
          "fileName": "tumbler.png",
          "contentType": "image/png",
          "mimeGroups": ["Image"],
          "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
          "detail": { "size": 50847, "image": { "width": 900, "height": 900 } }
        }
      }
    },
    "metadata": { "tags": [] }
  }
}
```

```api-endpoint
{
  "title": "Unarchive Media",
  "method": "DELETE",
  "path": "/spaces/{spaceId}/medias/{mediaId}/archived",
  "description": "Unarchives a Media to return its status to Draft. The archive key disappears from the response. There is no request body.",
  "responseStatus": 200,
  "baseUrl": "https://cma.weegloo.com/v1",
  "pathParameterSchema": {
    "spaceId": { "type": "string", "description": "The sys.id of the Space", "required": true },
    "mediaId": { "type": "string", "description": "The sys.id of the Media", "required": true }
  },
  "requestHeaderSchema": {
    "Authorization": { "type": "string", "description": "Bearer token (CMA authentication)" },
    "X-Weegloo-Version": { "type": "integer", "description": "The current resource's sys.version (optimistic concurrency control)" }
  },
  "responseExample": {
    "sys": {
      "id": "3trmXRM3RqbgSnifyg7PBe7ehkOn8e",
      "type": "Media",
      "space": { "sys": { "id": "tcq4V2Xb", "type": "Refer", "targetType": "Space" } },
      "publish": { "firstAt": "2026-06-18T10:11:46.712Z", "counter": 3 },
      "createdBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "createdAt": "2026-06-18T10:11:46.586Z",
      "updatedBy": { "sys": { "id": "3p4tcFbQRwz503VXdtHXNI5dZH5TVB", "type": "Refer", "targetType": "User" } },
      "updatedAt": "2026-06-18T10:12:50.000Z",
      "version": 7,
      "status": "Draft"
    },
    "fields": {
      "title": { "en-US": "Stainless Tumbler 500ml side shot" },
      "description": { "en-US": "Side product shot of the tumbler on a white background." },
      "file": {
        "en-US": {
          "fileName": "tumbler.png",
          "contentType": "image/png",
          "mimeGroups": ["Image"],
          "url": "https://weegloo-media.com/medias/tcq4V2Xb/n8e/3trmXRM3RqbgSnifyg7PBe7ehkOn8e/en-US/1/tumbler.png",
          "detail": { "size": 50847, "image": { "width": 900, "height": 900 } }
        }
      }
    },
    "metadata": { "tags": [] }
  }
}
```

## Related documents {#related-documents}

- [Upload API](/api/reference/upload-api.md): The request that uploads a file to get an *Upload* to use when creating a *Media*.
- [Content](/api/reference/cma/content.md): The body data that points to and uses a *Media* through a Refer field.
- [Tag](/api/reference/cma/tag.md): The classification labels attached in `metadata.tags`.
