# products.deliverable_save

Criar ou editar entregável. Sem `id` cria; com `id` altera nome, categoria e `config` (link, e-mail, webhook, evento ou área de membros: o que a categoria pede). `offerId` cria um entregável só daquela oferta. O Atomiks não entrega nada sozinho: guarda o que a oferta promete.

- Endpoint: `POST https://app.atomiks.com.br/api/v1/products.deliverable_save` (corpo JSON)
- Quem pode chamar: administrador da conta
- Escopo da chave: `crm:write`
- Grava dados: sim
- Pela chave de API: sim
- Ferramenta MCP: `products_deliverable_save`
- Ficha em JSON: `https://app.atomiks.com.br/api/v1/openapi.json` (operationId `products.deliverable_save`)

## Entrada

| Campo | Tipo | Obrigatório | Nota |
|---|---|---|---|
| `productId` | string (uuid) | sim |  |
| `id` | string (uuid) | não |  |
| `offerId` | string (uuid) \| null | não |  |
| `category` | "file" \| "link" \| "event" \| "email" \| "membership" \| "internal_membership" \| "webhook" | sim |  |
| `name` | string | sim |  |
| `config` | object | não |  |

<details><summary>JSON Schema</summary>

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "productId": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "id": {
      "type": "string",
      "format": "uuid",
      "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
    },
    "offerId": {
      "anyOf": [
        {
          "type": "string",
          "format": "uuid",
          "pattern": "^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$"
        },
        {
          "type": "null"
        }
      ]
    },
    "category": {
      "type": "string",
      "enum": [
        "file",
        "link",
        "event",
        "email",
        "membership",
        "internal_membership",
        "webhook"
      ]
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 120
    },
    "config": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    }
  },
  "required": [
    "productId",
    "category",
    "name"
  ]
}
```

</details>

## Exemplo

```bash
curl -X POST https://app.atomiks.com.br/api/v1/products.deliverable_save \
  -H "Authorization: Bearer $ATOMIKS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"productId":"00000000-0000-0000-0000-000000000000","category":"link","name":"Acesso ao curso","config":{"url":"https://exemplo.com/curso"}}'
```

CLI:

```bash
node cli/atomiks.mjs products.deliverable_save --json '{"productId":"00000000-0000-0000-0000-000000000000","category":"link","name":"Acesso ao curso","config":{"url":"https://exemplo.com/curso"}}'
```

MCP: ferramenta `products_deliverable_save` com a mesma entrada.

## Saída

Sucesso: `{"data": ...}` com o formato abaixo.

```json
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "id": {
      "type": "string"
    },
    "productId": {
      "type": "string"
    },
    "offerId": {
      "type": [
        "string",
        "null"
      ]
    },
    "category": {
      "type": "string",
      "enum": [
        "file",
        "link",
        "event",
        "email",
        "membership",
        "internal_membership",
        "webhook"
      ]
    },
    "name": {
      "type": "string"
    },
    "config": {
      "type": "object",
      "propertyNames": {
        "type": "string"
      },
      "additionalProperties": {}
    },
    "createdAt": {
      "type": "string"
    }
  },
  "required": [
    "id",
    "productId",
    "offerId",
    "category",
    "name",
    "config",
    "createdAt"
  ],
  "additionalProperties": false
}
```

## Erros

`{"error": {"code", "message", "requestId"}}`. Códigos: `invalid_input` (400), `unauthorized` (401), `forbidden` / `account_pending` / `scope_missing` (403), `not_found` (404), `limit_reached` (409), `internal` (500).
