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

# Update the fiscal profile

> Saves every valid field it receives and changes nothing else.

> [!WARNING]
>
> **Beta.** Melso does not serve this operation yet, and its fields can still change. See [what is live](https://docs.melso.ai/api/overview.md#what-is-live).

The answer is the profile with `errors` (each refused field and why), `deduced` (what Melso filled in, such as the province from the postal code) and `missing`. An empty value does not empty a field: name it in `clear`.


## OpenAPI

````yaml api/openapi.yaml PATCH /companies/{company_id}/fiscal-profile
openapi: 3.1.0
info:
  title: Melso API
  version: 1.0.0
  summary: Everything a Melso company does, from your own system.
  description: |
    The Melso API works in a Melso company: its invoices and customers, its
    books, its fiscal profile and digital certificate, its tax returns and its
    payroll.

    A company API key, which the company's owner creates in the Melso app,
    works in that one company. A partner key works in every company of its
    firm, with the company's `id` in the path. See
    [Authentication](/api/authentication).

    Invoicing is live. The other operations are in beta: each page says so,
    and their fields can still change until they are served.
  contact:
    name: Melso
    email: hello@melso.ai
    url: https://docs.melso.ai/api/overview
servers:
  - url: https://api.melso.ai/v1
security:
  - companyApiKey: []
  - partnerApiKey: []
tags:
  - name: Companies
    description: The companies the key works in.
  - name: Fiscal profile
    description: What decides which returns a company files.
  - name: Digital certificate
    description: >-
      The certificate Melso files with, which your system uploads or the owner
      uploads on a Melso page.
  - name: Customers
    description: The company's invoice customers.
  - name: Invoices
    description: >-
      Drafts, issuing through VERI*FACTU, corrections, voiding, payment and the
      PDF.
  - name: Expenses
    description: Received invoices and receipts, recorded in the company's books.
  - name: Income
    description: Invoices the company issued outside Melso, recorded in its books.
  - name: Documents
    description: Invoices and receipts that Melso reads and records for you.
  - name: VAT book imports
    description: The VAT books a company kept in another program, imported whole.
  - name: Tax returns
    description: >-
      The tax calendar, the returns Melso calculates, their approval and their
      receipts.
  - name: Payroll settings
    description: The company's labour data, and payslip simulations.
  - name: Employees
    description: Employees, their contract terms, modelo 145 and documents.
  - name: Contracts
    description: >-
      Contracts, extensions and conversions, and their communication to
      Contrat@.
  - name: Payroll runs
    description: Each month's payroll, from draft to approved and paid.
  - name: Payslips
    description: >-
      One employee's payslip in a month, its incidents and the official payroll
      files.
  - name: Social Security
    description: Liquidations with the TGSS, the SILTRA files and the TGSS's answers.
  - name: Leaves and strikes
    description: Sick leaves from the INSS's FIE files, and strikes.
paths:
  /companies/{company_id}/fiscal-profile:
    parameters:
      - $ref: '#/components/parameters/CompanyId'
    patch:
      tags:
        - Fiscal profile
      summary: Update the fiscal profile
      description: >
        Saves every valid field it receives and changes nothing else.


        The answer is the profile with `errors` (each refused field and why),
        `deduced` (what Melso filled in, such as the province from the postal
        code) and `missing`. An empty value does not empty a field: name it in
        `clear`.
      operationId: updateFiscalProfile
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/FiscalProfileInput'
            example:
              legal_name: Brasa Norte S.L.
              trade_name: Brasa Norte
              postal_code: 8018
              activity_description: Restaurante de cocina mediterránea
              iae_code: '671.4'
              vat_regime: general
      responses:
        '200':
          description: The saved profile.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/FiscalProfileAnswer'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
        '409':
          $ref: '#/components/responses/Conflict'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  parameters:
    CompanyId:
      name: company_id
      in: path
      required: true
      description: >-
        The company's ID. Every company-scoped call works in exactly this
        company.
      schema:
        type: string
        format: uuid
  schemas:
    FiscalProfileInput:
      allOf:
        - $ref: '#/components/schemas/FiscalProfile'
        - type: object
          properties:
            clear:
              type: array
              items:
                type: string
              description: Names of fields to empty.
    FiscalProfileAnswer:
      type: object
      required:
        - fiscal_profile
        - deduced
        - errors
        - missing
      properties:
        fiscal_profile:
          $ref: '#/components/schemas/FiscalProfile'
        deduced:
          type: array
          items:
            type: string
          description: Fields Melso filled in, such as `province` from the postal code.
        errors:
          type: array
          items:
            $ref: '#/components/schemas/FieldError'
          description: Each refused field and why.
        missing:
          type: array
          items:
            type: string
          description: >-
            What Melso still needs before it can do the taxes, such as
            `iae_code` or `certificate`.
    FiscalProfile:
      type: object
      properties:
        tax_id:
          type: string
          description: 'The NIF: a DNI, NIE or CIF. Its control character is checked.'
        legal_name:
          type: string
          description: The full name on the DNI or NIE, or the company's registered name.
        trade_name:
          type: string
          description: The name the business trades under
          when different.: null
        address:
          type: string
          description: 'Fiscal address: street, number, floor.'
        postal_code:
          type: string
          description: Five digits. Also sets the province and the tax territory.
        city:
          type: string
          description: Municipality.
        province:
          type: string
          description: Normally deduced from the postal code.
        tax_territory:
          type: string
          enum:
            - comun
            - alava
            - bizkaia
            - gipuzkoa
            - navarra
            - canarias
            - ceuta
            - melilla
          description: Normally deduced from the postal code. Send it only to correct that.
        activity_type:
          type: string
          enum:
            - profesional
            - empresarial
          description: >-
            A self-employed person's main activity. A company's is always
            `empresarial`.
        activity_description:
          type: string
          description: What the business does.
        iae_code:
          type: string
          description: >-
            The main IAE heading, such as `671.4` for a restaurant or `673.2`
            for a bar.
        activities:
          type: array
          items:
            $ref: '#/components/schemas/Activity'
          description: >-
            The other activities beside the main one, one per other IAE heading
            in the census (modelo 036). Sending it replaces the list: send every
            other activity, each saved one with its `id`. Removing one that has
            invoices, income or expenses is refused; set its `ended_on` instead.
        client_types:
          type: array
          items:
            type: string
            enum:
              - es_business
              - es_individual
              - eu_business
              - non_eu_business
          description: >-
            Who the business invoices, every kind that applies. Sending it
            replaces the list. Without `eu_business`, `eu_operator` is saved as
            `false`.
        eu_operator:
          type: boolean
          description: Registered as an intra-community operator (ROI).
        vat_regime:
          type: string
          enum:
            - general
            - recargo_equivalencia
            - simplificado
            - reagp
            - exento
            - igic_general
            - igic_simplificado
            - igic_repep
            - ipsi
          description: >-
            Defaults to `general`, IGIC in the Canary Islands and IPSI in Ceuta
            and Melilla.
        vat_sii:
          type: boolean
          description: >-
            Keeps its VAT books in the AEAT's SII, compulsory for large
            companies.
        vat_redeme:
          type: boolean
          description: >-
            In the monthly VAT refund register (REDEME), so it files VAT
            monthly.
        is_large_company:
          type: boolean
          description: >-
            Volume of operations over 6,010,121.04 euros last year: VAT and
            withholdings are filed monthly.
        irpf_method:
          type: string
          enum:
            - directa_simplificada
            - directa_normal
            - modulos
          default: directa_simplificada
          description: Self-employed only.
        irpf_retention_rate:
          type: number
          minimum: 0
          maximum: 100
          description: >-
            Income tax withheld on a self-employed person's invoices, in
            percent. Defaults to 15 for a professional. Self-employed only.
        registration_status:
          type: string
          enum:
            - alta
            - pendiente
          description: 'Self-employed only: `alta` when already registered.'
        registered_on:
          type: string
          description: >-
            When the self-employed person registered: `YYYY-MM`, or `YYYY-MM-DD`
            when the day is known.
        invoice_series:
          type: string
          description: Invoice series prefix.
        next_invoice_number:
          type: integer
          minimum: 1
          description: >-
            The number the next invoice takes, continuing the business's own
            numbering.
        iban:
          type: string
          description: The account invoices are collected in. Masked when read.
    FieldError:
      type: object
      required:
        - field
        - error
      properties:
        field:
          type: string
        error:
          type: string
    Error:
      type: object
      required:
        - error
        - code
        - request_id
      properties:
        error:
          type: string
          description: What went wrong, for a person to read.
        code:
          type: string
          description: >-
            A stable code to branch on, such as `invoicing_not_ready` or
            `version_conflict`.
        request_id:
          type: string
          description: >-
            The same value as the `X-Request-Id` header. Quote it when you
            contact Melso.
        field:
          type: string
          description: The field, query parameter or header at fault, when there is one.
        next_action:
          type: string
          description: >-
            A stable hint of what to do next, such as `review_plan`, when the
            operation gives one.
        payment_url:
          type: string
          format: uri
          description: >-
            Where the company's owner pays its plan, on `plan_required` when its
            plan is unpaid.
        current_version:
          type: string
          description: On `version_changed`, the object's current `version`.
    Activity:
      type: object
      required:
        - iae_code
      additionalProperties: false
      properties:
        id:
          type: string
          description: The saved activity's ID, from a read. Omit it to add an activity.
        iae_code:
          type: string
          description: Its IAE heading, such as `659.9` or `843.1`.
        activity_type:
          type: string
          enum:
            - profesional
            - empresarial
          description: A company's activities are always `empresarial`.
        description:
          type: string
          description: What the activity is.
        vat_regime:
          type:
            - string
            - 'null'
          enum:
            - general
            - recargo_equivalencia
            - simplificado
            - reagp
            - exento
            - igic_general
            - igic_simplificado
            - igic_repep
            - ipsi
            - ''
            - null
          description: >-
            Only when it differs from the main activity's, such as
            `recargo_equivalencia` for a shop. Empty follows the main one.
        started_on:
          type: string
          format: date
          description: Its registration date
          when known.: null
        ended_on:
          type:
            - string
            - 'null'
          format: date
          description: Its deregistration date, once it has ended.
  responses:
    BadRequest:
      description: |
        The request is malformed or a field is invalid. Unknown body fields and
        query parameters are refused too, with `field` naming them where it can.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            invalid_invoice:
              summary: A field the invoice cannot take
              value:
                error: vat_rate must be 21, 10, 4 or 0 (exempt)
                code: invalid_invoice
                next_action: review_request
                request_id: req_8f14e45fceea167a5a36dedd
            unknown_field:
              summary: A field the operation does not take
              value:
                error: Unknown field iban
                code: invalid_arguments
                field: iban
                request_id: req_8f14e45fceea167a5a36dedd
    Unauthorized:
      description: |
        The key is missing, revoked or invalid (`invalid_api_key`), or it is a
        test key, which Melso does not issue (`test_keys_unavailable`).
      headers:
        WWW-Authenticate:
          description: '`Bearer realm="api.melso.ai"` on `invalid_api_key`.'
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: The API key is missing, revoked or invalid
            code: invalid_api_key
            request_id: req_8f14e45fceea167a5a36dedd
    Forbidden:
      description: >
        Refused in this company: the operation is not available in it, such as

        invoices before its VERI*FACTU set-up (`tool_unavailable`); a

        self-employed person's setup in Melso is pending
        (`onboarding_required`); or the

        key's creator lacks the role the operation needs, such as the owner's

        for issuing (`forbidden`).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: invoices is not available in this company
            code: tool_unavailable
            next_action: check_company_and_access
            request_id: req_8f14e45fceea167a5a36dedd
    NotFound:
      description: >-
        No such object in this company, or `company_id` is not the key's
        company.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: invoice not found
            code: not_found
            next_action: refresh_record
            request_id: req_8f14e45fceea167a5a36dedd
    Conflict:
      description: |
        The object changed or is not in a state that allows this: read it again
        and decide. Also the first request with this `Idempotency-Key` still
        running (`idempotency_key_in_use`, with `Retry-After: 1`).
      headers:
        Retry-After:
          description: Seconds to wait, on `idempotency_key_in_use`.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 'invoice changed: review the current draft'
            code: version_conflict
            field: expected_version
            next_action: refresh_and_request_authorization
            request_id: req_8f14e45fceea167a5a36dedd
    RateLimited:
      description: >-
        The key made more than 600 requests in a minute. Wait `Retry-After`
        seconds.
      headers:
        Retry-After:
          description: Seconds to wait, `60`.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error: 'Too many requests: a key makes at most 600 a minute'
            code: rate_limited
            request_id: req_8f14e45fceea167a5a36dedd
  securitySchemes:
    companyApiKey:
      type: http
      scheme: bearer
      description: |
        A company API key, `mk_live_…`, that the company's owner creates in the
        Melso app under Settings, Connect your AI, API keys. It works in that
        one company with the owner's authority. Test keys (`mk_test_…`) are not
        issued. Keep the key on your servers. See
        [Authentication](/api/authentication).
    partnerApiKey:
      type: http
      scheme: bearer
      description: >
        A partner key of your firm, which the firm's owner or an admin creates
        in

        Melso under Settings, Developers, with the permissions it needs. It
        works in

        every company of the firm: put the company's `id` in the path. A company

        that is not your firm's answers `404`. Early access. See

        [Acting for your companies](/api/partner/acting-for-companies).

````

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