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

# Employees and payroll

> Register employees and contracts, run each month's payroll, get the payslips and keep the Social Security up to date. Beta.

> [!WARNING]
>
> **Beta.** Melso does not serve the payroll endpoints yet, and their fields can
> still change. Keep them behind a flag in your product.

> [!NOTE]
>
> These calls work with a company key in its own company, or with a
> [partner key](https://docs.melso.ai/api/partner/acting-for-companies.md) in any company of the firm.
> `$MELSO_API_KEY` is either one.

Register each employee when the company hires them. Melso's professionals do
the registration with the Social Security, communicate contracts to Contrat@
and prepare each month's payroll.

## 1. Set up the company's labour data once

The Social Security accounts (CCC), the collective agreement, the mutua and
the account salaries leave from. Read them with
[Get the labour settings](https://docs.melso.ai/api/reference/payroll-settings/get-payroll-settings.md)
and send what is missing with
[Update the labour settings](https://docs.melso.ai/api/reference/payroll-settings/update-payroll-settings.md).

## 2. Register an employee

Send only what the employee confirmed. An employee without a full profile is
kept, and the month's payroll lists them as incomplete.

```bash theme={null}
curl https://api.melso.ai/v1/companies/$COMPANY_ID/employees \
  -H "Authorization: Bearer $MELSO_API_KEY" \
  -H "Idempotency-Key: employee-emp_1022" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "Marc Puig Soler",
    "start_date": "2026-12-01",
    "profile": {
      "nif": "00000001R",
      "naf": "080000000000",
      "contract": "indefinido",
      "category": "Cocinero",
      "group": 8,
      "weekly_hours": "40",
      "full_time_hours": "40",
      "annual_salary": "21000.00"
    }
  }'
```

`incomplete` lists what the payroll still needs from them. To see what a hire
would cost before you make it, use
[Preview a payslip](https://docs.melso.ai/api/reference/payroll-settings/preview-payslip.md).

## 3. Register the contract and send it to Contrat@

[Create a contract](https://docs.melso.ai/api/reference/contracts/create-contract.md) with its SEPE
clave, account, occupation and hours. Then
[send it to Contrat@](https://docs.melso.ai/api/reference/contracts/submit-contract-to-contrata.md)
within 10 days, and follow the SEPE's answer in
[List Contrat@ submissions](https://docs.melso.ai/api/reference/contracts/list-contrata-submissions.md).
Extensions and conversions are contracts too, with `event` and `previous_id`.

## 4. Run the month

| Step | Endpoint |
| - | - |
| Open the month as a draft | [Create a payroll run](https://docs.melso.ai/api/reference/payroll-runs/create-payroll-run.md) |
| Record overtime, bonuses, unpaid days or a leaver | [Update a payslip's incidents](https://docs.melso.ai/api/reference/payslips/update-payslip-incidents.md) |
| Let the company review it | [Create an approval link](https://docs.melso.ai/api/reference/payroll-runs/create-payroll-approval-link.md) |
| Approve it at the version reviewed | [Approve a payroll run](https://docs.melso.ai/api/reference/payroll-runs/approve-payroll-run.md) |
| Record that salaries were paid | [Mark a payroll run paid](https://docs.melso.ai/api/reference/payroll-runs/mark-payroll-run-paid.md) |

Every change of state sends the run's `version` as `expected_version`. If the
month changed in between, the call answers `409`: read it again.

## 5. Get the payslips and files

[Download a payroll file](https://docs.melso.ai/api/reference/payslips/get-payroll-file.md) gives the
payslips and settlements as PDF, the SEPA transfer file and the official
files, with `scope` and `kind`.

```bash theme={null}
curl -o payslips.zip "https://api.melso.ai/v1/companies/$COMPANY_ID/payroll/files?scope=run&kind=payslips&id=$RUN_ID" \
  -H "Authorization: Bearer $MELSO_API_KEY"
```

## 6. Social Security

After a month is approved, generate its file for SILTRA with
[Generate a SILTRA file](https://docs.melso.ai/api/reference/social-security/generate-siltra-file.md),
then import what the TGSS answers with
[Import a TGSS answer](https://docs.melso.ai/api/reference/social-security/import-red-response.md).
[List Social Security liquidations](https://docs.melso.ai/api/reference/social-security/list-liquidations.md)
shows what is due and when.

Sick leaves come from the INSS's FIE files:
[import each one](https://docs.melso.ai/api/reference/leaves-and-strikes/import-fie-file.md) and the
next month's payroll applies them.

## When someone leaves

Record the termination in the month's incidents, so the payroll calculates the
settlement (finiquito). Then
[update the employee](https://docs.melso.ai/api/reference/employees/update-employee.md) with
`active: false` and `end_date`.


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