# Create image

{% hint style="info" %}
**Before getting started:** You will need to [create your API key](/api/create-api-key.md).
{% endhint %}

## Create and return a new image URL

<mark style="color:green;">`POST`</mark> `https://mtmx.io/v1/image`

#### Headers

| Name                                            | Type   | Description           |
| ----------------------------------------------- | ------ | --------------------- |
| Authorization<mark style="color:red;">\*</mark> | String | `Bearer YOUR-API-KEY` |

#### Request Body

| Name                                   | Type    | Description                                                                                                  |
| -------------------------------------- | ------- | ------------------------------------------------------------------------------------------------------------ |
| html<mark style="color:red;">\*</mark> | String  | The HTML you want to render for creating an image.                                                           |
| content                                | Object  | Updates values when using Handlebars templating syntax. [Learn more](/api/template-syntax.md).               |
| type                                   | String  | Defines whether to render JPEG or PNG image. Accepted values are `png` and `jpeg`. Default value is `png`.   |
| quality                                | Number  | Defines the quality of JPG images. Not applicable to PNG images. Default value `80`.                         |
| selector                               | String  | Target a specific HTML element to perform the screenshot. Default value is `body`.                           |
| transparent                            | Boolean | Hides default white background and allows capturing screenshots with transparency. Default value is `false`. |

{% tabs %}
{% tab title="200: OK Export created successfully" %}

```javascript
{
    "success": true,
    "url": "https://cdn.mattermix.com/v1/image/62029ad452390ccfd9abcc4f-1644951564719.png"
    "id": "620bfdd2501f2b5c901e2800"
}
```

{% endtab %}

{% tab title="401: Unauthorized Unauthorized request" %}

```javascript
{
    "success": false,
    "statusCode": 401,
    "message": "Please provide a valid API key."
}
```

{% endtab %}

{% tab title="402: Payment Required Inactive or cancelled subscription" %}

```javascript
{
    "success": false,
    "statusCode": 402,
    "message": "Active subscription not found."
}
```

{% endtab %}

{% tab title="500: Internal Server Error Internal server error" %}

```javascript
{
    "success": false,
    "statusCode": 500,
    "message": "Server error."
}
```

{% endtab %}

{% tab title="429: Too Many Requests API limit reached" %}

```javascript
{
    "success": false,
    "statusCode": 429,
    "message": "You have reached your monthly export limit set in your account."
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.mattermix.com/api/create-image.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
