# Creatives

Schema: [Creative](schemas.md#creative)

## POST /creatives — Add a new creative

`operationId: addCreative` · Body: `Creative` (required).

Required properties by type:

| Type   | Required                                                            |
| ------ | ------------------------------------------------------------------- |
| image  | name, type, destination, image_url, size                            |
| script | name, type, content, size                                           |
| native | name, type, destination, image_url, title, description, display_url |
| text   | name, type, destination, title, description, display_url            |

### Macros for `destination` URL

**Image:** `[CACHEBUSTER]`, `[PAGE_URL]`, `[DOMAIN]`, `[REF]` (referrer of page URL), `[PARTNER_ID]` (SSP source id), `[PUBLISHER_ID]`, `[CAMPAIGN_ID]`, `[RTB_CAT]` (category, if available).

**Text:** `[KEYWORD]`, `[PLACEMENT]` (ad position in network), `[AID]` (source id), `[CITY]`, `[STATE]`, `[UID]` (unique click id for S2S postback), `[SUBID]` (subsource id), `[CAMPAIGN_ID]`.

Responses: `201` created, `400` errors, `422` unprocessable entity.

## GET /creatives — List creatives

`operationId: listCreatives`

| Query param | Type    | Description                         |
| ----------- | ------- | ----------------------------------- |
| type        | string  | `image`, `script`, `text`, `native` |
| status      | string  | `A` active, `S` paused              |
| search      | string  | Search by keyword                   |
| order       | string  | `field:asc                          | desc,...` |
| offset      | integer | Default 0                           |
| limit       | integer | Default 20                          |

`200`: array of `{ id, name, type, status, size }`. `404`: none found.

## GET /creatives/{creativeId} — Find creative by ID

`operationId: getCreativeById` · `200`: `Creative` · `404`: not found.

## PATCH /creatives/{creativeId} — Update a creative

`operationId: updateCreative` · Body: `Creative` (required).

**type** cannot be changed and is ignored. Only properties relevant to the creative's type are processed (see table above); others are ignored.

Responses: `400` invalid ID, `404` not found, `405` validation exception.

## DELETE /creatives/{creativeId} — Delete a creative

`operationId: deleteCreative` · `204` deleted, `400` errors, `404` not found.

## GET /creatives/sizes — List creative sizes

`operationId: listCreativesSizes` · `200` success.
