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

> ## Agent Instructions
> Melso MCP: https://mcp.melso.ai/mcp (OAuth; one company per connection). Documentation-search MCP: https://docs.melso.ai/mcp; it does not act on customer accounts. Melso API: https://api.melso.ai/v1, with a company API key or a partner key (early access); invoicing is live and the other operations are marked beta.
>
> Use the live tool list and respect company membership. Ask the person to approve the exact invoice or tax return version in the signed-in app. Melso's professionals prepare and file included returns after approval; an AI assistant does not file. A prepared file or an approval is not evidence of filing: only the AEAT's reference and receipt are. Keep credentials out of chat and logs.

# Limits and errors

> Rate limits, safe retries with Idempotency-Key, billing errors and the error format of the Partner API.

## Rate limits

Each key can make 600 requests a minute. Above that, Melso answers `429` with
a `Retry-After` header in seconds: wait that long and retry.

Calls for different companies run in parallel. To load a large history, send
one [VAT book import](https://docs.melso.ai/api/partner/guides/books.md#import-a-vat-book) per company
rather than thousands of single expenses.

## Retry safely

Every `POST` to a partner endpoint takes an `Idempotency-Key` header, up to 255
characters. Use a fresh UUID per operation, and the same one when you retry it.

| Retry | Answer |
| - | - |
| Same key, same body, within 24 hours | The first answer again, with `Idempotent-Replayed: true`. |
| Same key, different body | `422` `idempotency_key_reused`. |
| Same key while the first call still runs | `409`. Wait `Retry-After` seconds. |

Retry on a timeout, a network error, `429` and any `5xx`. Never retry a `4xx`
other than `409` and `429` without changing the request.

## Errors

Every error has the same body:

```json theme={null}
{
  "error": "Another company of your firm already has this NIF.",
  "code": "conflict",
  "field": "tax_id",
  "request_id": "req_4f1a9b2c"
}
```

Branch on `code`, show `error` to a person if you need to, and send
`request_id` when you write to us.

| Status | `code` | Meaning |
| - | - | - |
| `400` | `invalid_request`, `invalid_arguments` | A field is invalid or unknown. `field` names it. |
| `401` | `invalid_api_key` | The key is missing, revoked, or for the other environment. |
| `402` | `gestoria_payment_method_required` | Your firm has no payment method yet. `payment_url` opens the page to add one. |
| `402` | `gestoria_unpaid` | Your firm has an unpaid invoice. |
| `403` | `missing_permission` | The key lacks the permission named in `permission`. |
| `403` | `partner_key_required` | A partner endpoint was called with a company key. |
| `404` | `not_found` | The company is not your firm's, or the object does not exist in it. |
| `409` | `conflict` | A conflict, such as a NIF or `external_id` already in your firm, or a stale `version`. |
| `422` | `idempotency_key_reused` | This `Idempotency-Key` came with a different request. |
| `429` | `rate_limited` | Over the rate limit. Wait `Retry-After` seconds. |

## Billing

Your firm pays Melso for its companies. They have no plan or trial of their
own, and the API never charges your customers. Write to
[hello@melso.ai](mailto:hello@melso.ai) for your firm's pricing.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.