# Links

Create tracked links.

Create tracked links.

## Create links

`POST /v1/links/`

Required scope: `links:write`

### Parameters

| Name | In | Type | Required | Notes |
| --- | --- | --- | --- | --- |
| `Idempotency-Key` | header | string (uuid) | Yes | UUID4 identifying one intended write. Reuse it only when retrying that same write. |

### Request body

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `destination_url` | string (uri) | Yes | max length 2048 |
| `name` | string | Yes | max length 255 |
| `og_description` | string | No | max length 5000 |
| `og_image_url` | string (uri) | No | max length 2048 |
| `og_title` | string | No | max length 255 |
| `slug` | string | No | max length 255 |

### Response (201)

| Field | Type | Required | Notes |
| --- | --- | --- | --- |
| `created_at` | string (date-time) | No | read-only |
| `destination_url` | string | No | read-only |
| `domain` | string | No | read-only |
| `id` | string | No | read-only |
| `name` | string | No | read-only |
| `og_description` | string | No | read-only |
| `og_image_url` | string | No | read-only |
| `og_title` | string | No | read-only |
| `short_url` | string | No | read-only |
| `slug` | string | No | read-only |

### Responses

- `201` Success
- `400` The request is invalid.
- `401` Authentication is missing, invalid, or revoked.
- `403` The authenticated identity lacks the required scope or capability.
- `404` The resource is unavailable or not visible to this organization.
- `409` The write conflicts with current state or an identical request is still running.
- `422` The write contains fields outside its closed input schema.
- `429` The request-rate budget is exhausted.

```bash
curl -X POST "https://api.themochi.app/v1/links/" \
  -H "Authorization: Bearer $MOCHI_API_KEY" \
  -H "Idempotency-Key: $(uuidgen | tr A-Z a-z)" \
  -H "Content-Type: application/json" \
  -d '{"destination_url":"string","name":"string"}'
```

