> ## 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.

# Partner API authentication

> Create a partner key in the Melso console, choose its permissions, keep it on your servers and revoke it when you need to.

Every request carries a partner key of your firm as a bearer token. The same
key calls the partner endpoints and the [Melso API](https://docs.melso.ai/api/overview.md) for any
company of your firm.

```bash theme={null}
curl https://api.melso.ai/v1/partner/companies \
  -H "Authorization: Bearer $MELSO_PARTNER_KEY"
```

## Test and live keys

A key is for one environment. An `mk_test_` key works only in Melso's test
environment, where nothing is filed with the AEAT. An `mk_live_` key works only
in production. A key sent to the other environment answers `401`. Build with a
test key, and ask [hello@melso.ai](mailto:hello@melso.ai) for the test
environment's address.

## Create a key

**1. Open the console**

Sign in to Melso as the firm's owner or an admin, and go to
**Settings** › **Developers**.

**2. Choose its permissions**

Give the key only what it needs. A backend that onboards customers, sends
their books and approves their returns needs `companies:write`,
`incorporations:write`, `fiscal_profile:write`, `certificates:write`,
`books:write`, `taxes:write` and `webhooks:write`. Each `:write` includes its
`:read`.

**3. Copy the secret**

The secret is shown once. Store it in your server's secret manager, such as
an environment variable `MELSO_PARTNER_KEY`.

## Keep it safe

* Use the key only from your servers. Never in a browser, a mobile app, a log
  or a repository.
* Revoke a key from the same page in **Settings** › **Developers**. It stops working
  at once.
* A key also stops working when the person who created it leaves the firm.
  Create the key from an account that stays.

## Errors

| Status | `code` | Meaning |
| - | - | - |
| `401` | `invalid_api_key` | Missing, revoked or invalid key. |
| `403` | `missing_permission` | The key lacks the permission named in `permission`. |
| `403` | `partner_key_required` | A partner endpoint was called with a company key. |

[Acting for your companies](https://docs.melso.ai/api/partner/acting-for-companies.md#permissions)
lists every permission and the endpoints it opens. A firm has at most 20 keys.


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