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

> From a test key to a customer company ready for its taxes in five calls: create it, complete its profile, upload its certificate, add a webhook.

> [!NOTE]
>
> **Early access.** Your firm's owner or an admin creates partner keys in the
> Melso console, under **Settings** › **Developers**.

This guide takes one customer business that already has its NIF from nothing
to ready for its taxes, in five calls. Steps 3 to 5 are in beta.

**1. Get a test key**

Create a partner key in **Settings** › **Developers** with `companies:write`,
`fiscal_profile:write`, `certificates:write` and `webhooks:write`. The secret
is shown once.

```bash theme={null}
export MELSO_PARTNER_KEY="mk_test_..."
```

An `mk_test_` key works only in Melso's test environment, where nothing is
filed. See [Authentication](https://docs.melso.ai/api/partner/authentication.md).

**2. Create the company**

```bash theme={null}
curl https://api.melso.ai/v1/partner/companies \
  -H "Authorization: Bearer $MELSO_PARTNER_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{
    "kind": "company",
    "name": "Brasa Norte S.L.",
    "company_form": "sl",
    "tax_id": "B00000000",
    "external_id": "ws_48213",
    "fiscal_profile": {
      "address": "Carrer de Pallars 100",
      "postal_code": "08018",
      "tax_territory": "comun",
      "activity_type": "empresarial",
      "iae_code": "671.4",
      "vat_regime": "general"
    }
  }'
```

Store `company.id`. `missing` lists what Melso still needs.

**3. Complete the fiscal profile**

From here on, every call is the [Melso API](https://docs.melso.ai/api/partner/acting-for-companies.md)
with the company's `id` in the path.

```bash theme={null}
curl -X PATCH https://api.melso.ai/v1/companies/$COMPANY_ID/fiscal-profile \
  -H "Authorization: Bearer $MELSO_PARTNER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"vat_sii": false, "vat_redeme": false, "is_large_company": false}'
```

Repeat until `missing` holds only `certificate`.

**4. Upload the certificate**

```bash theme={null}
curl https://api.melso.ai/v1/companies/$COMPANY_ID/certificate \
  -H "Authorization: Bearer $MELSO_PARTNER_KEY" \
  -H "Content-Type: application/json" \
  -d "{\"file\": \"$(base64 -i certificate.p12)\", \"password\": \"$CERTIFICATE_PASSWORD\"}"
```

`missing` is now empty: Melso's professionals can do the company's taxes.

**5. Listen for what happens next**

```bash theme={null}
curl https://api.melso.ai/v1/partner/webhook-endpoints \
  -H "Authorization: Bearer $MELSO_PARTNER_KEY" \
  -H "Content-Type: application/json" \
  -d '{"url": "https://example.com/melso/webhooks", "events": ["company.*", "tax_return.*"]}'
```

You get `tax_return.approval_pending` when a return is ready for the company
to [approve](https://docs.melso.ai/api/partner/guides/approvals.md), and `tax_return.filed` once Melso
has filed it.

## Next

* [Onboard an existing business](https://docs.melso.ai/api/partner/guides/existing-business.md): every field, in detail.
* [Send the books](https://docs.melso.ai/api/partner/guides/books.md): expenses, income, documents and VAT books.
* [Build with an AI agent](https://docs.melso.ai/api/partner/build-with-ai.md): the prompt for your coding agent.


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