---
title: "Generate a diagram"
description: "Costs one credit, also to refine a creative diagram. Returns the completed generation with its SVG; a failed generation is refunded. The request's x-client-action-id is stored, so a client that lost the response can find the generation."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.svgdiagram.ai/llms.txt
> Use this file to discover all available pages before exploring further.

Path: svgdiagram API › Generations

`POST /rest/v1/generations`

Costs one credit, also to refine a creative diagram. Returns the completed generation with its SVG; a failed generation is refunded. The request's x-client-action-id is stored, so a client that lost the response can find the generation.

## Authentication

- `bearerAuth`, http, header `Authorization`

## Code samples

### cURL

```curl
curl --request POST \
  --url https://svgdiagram.ai/rest/v1/generations \
  --header 'Authorization: Bearer <token>'
```

### TypeScript

```typescript
const url = 'https://svgdiagram.ai/rest/v1/generations';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

fetch(url, options)
  .then(res => res.json())
  .then(json => console.log(json))
  .catch(err => console.error(err));
```

### Python

```python
import requests

url = "https://svgdiagram.ai/rest/v1/generations"

headers = {"Authorization": "Bearer <token>"}

response = requests.post(url, headers=headers)

print(response.text)
```

## Responses

### 201

Generated diagram

#### Example

```json
{}
```

### 400

Invalid request, options, or export

#### Example

```json
{}
```

### 402

No credit or billing entitlement

#### Example

```json
{}
```

### 404

Unknown design, or the generation to try again from or refine was not found

#### Example

```json
{}
```

### 422

The chosen design does not fit the request

#### Example

```json
{}
```

### 502

The model or renderer failed

#### Example

```json
{}
```

### 503

At capacity

#### Example

```json
{}
```


Source: https://docs.svgdiagram.ai/api/Generations/postRestV1Generations/index.md
