# createAsset mutation


`createAsset` is a GraphQL mutation of the Chameleoon MAX API. Send it as `POST https://max-api.chameleoon.sk/api/v1/graphql` with your API key, see [Chameleoon MAX](/chameleoon-max).

Creates an asset from an image you uploaded. Call it after the upload to give the image a code
that print templates and e-mails can refer to.

Upload the image first through `POST /api/v1/assets/files` (multipart, field `file`): a PNG or
JPEG of at most 2 MiB and 4 000 000 pixels. Pass the returned `fileId` here.

#### Permissions

- Requires the `company.write` permission.
- A company's asset also requires the company in your API key's legal-entity scope.

#### Errors

| Code | Reason | When |
| --- | --- | --- |
| `CONFLICT` | `DUPLICATE_CODE` | An asset with the same reference already exists (field `code`). |
| `CONFLICT` | `FILE_ALREADY_ATTACHED` | The uploaded file is already used. Upload it again. |
| `NOT_FOUND` | | The file does not exist or has expired (`extensions.field` `fileId`), or the company does not exist (`extensions.field` `legalEntityId`). |
| `VALIDATION` | `CODE_SHAPE` | The `code` has the wrong shape. |
| `VALIDATION` | `NOT_PUBLISHABLE` | `isPublic` is `true` on a stamp. |
| `VALIDATION` | `TOO_MANY_PIXELS`, `UNREADABLE_IMAGE` | The image has too many pixels or cannot be read (field `fileId`). |

## Arguments

- `input`: [`CreateAssetInput!`](/chameleoon-max/type/create-asset-input) · required

## Returns

[`Asset!`](/chameleoon-max/type/asset)

## Example

**Mutation**

```graphql
mutation createAsset($input: CreateAssetInput!) {
  createAsset(input: $input) {
    id
    scope
    legalEntityId
    code
    reference
    name
    kind
    contentType
    width
    height
    sizeBytes
    isPublic
    publicUrl
    createdAt
    updatedAt
  }
}
```

**Variables**

```json
{
  "input": {
    "scope": "TENANT",
    "code": "example",
    "name": "example",
    "kind": "LOGO",
    "fileId": "00000000-0000-4000-8000-000000000001"
  }
}
```

**Response**

```json
{
  "data": {
    "createAsset": {
      "id": "00000000-0000-4000-8000-000000000001",
      "scope": "TENANT",
      "legalEntityId": "00000000-0000-4000-8000-000000000001",
      "code": "example",
      "reference": "example",
      "name": "example",
      "kind": "LOGO",
      "contentType": "example",
      "width": 1,
      "height": 1,
      "sizeBytes": 1,
      "isPublic": true,
      "publicUrl": "example",
      "createdAt": "2026-01-01T00:00:00Z",
      "updatedAt": "2026-01-01T00:00:00Z"
    }
  }
}
```

Values are illustrative: replace IDs and codes with your own before you send the call.
