openapi: 3.0.3
servers:
- url: https://api.verifacti.com/
info:
  title: NIFs Management API Documentation
  contact:
    email: info@verifacti.com
    name: Contact
    url: https://www.verifacti.com
  description: |

    # Basic operation

    Here you will find the technical documentation of our API for general management of your NIFs in our system. In particular,
    it can be used to register and deregister different NIFs in both VeriFactu and TicketBai, the VeriFactu counterpart in
    the Basque Country. NIFs can be registered in the test and production environments. Test NIFs send invoices to the
    administration's test environment and are not counted for billing.

    &nbsp;

    For a small number of NIFs, you can create, modify and deregister them manually using our platform.
    However, for a large volume of NIFs this becomes impractical, so we provide this simple API
    to manage them. It is included in the price and can be used by any user with an active subscription.

    &nbsp;

    The VeriFactu API documentation can be found <a href="https://www.verifacti.com/docs">here</a>. For TicketBai, we provide
    a separate but completely analogous API to VeriFactu. Its documentation is <a href="https://www.verifacti.com/tb-docs">here</a>.

    &nbsp;

    On our platform, you will find an API key to make all your calls to this API, at https://app.verifacti.com/ajustes?tab=api-key. The most important endpoint is
    creating a NIF, which requires specifying the basic data as well as the tax authority to link it to and the environment.

    &nbsp;

    Webhook creation is also supported to receive the results of invoicing record creation.

    &nbsp;

    <a
      href="https://storage.googleapis.com/verifacti_non_sensitive/postman_nifs.json"
      download="nifs-docs.json"
      style="
        display: inline-block;
        padding: 6px 12px;
        background-color: #FF6C37;
        color: white;
        text-decoration: none;
        border-radius: 5px;
        font-weight: bold;
        font-family: Arial, sans-serif;
        box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    ">
      Postman Collection
    </a>

    &nbsp;
tags:
- name: NIFs
  description: |
    NIFs can be created in the test environment, which communicates with the administration's test environment. These are available
    at no additional cost and are never counted for billing. NIFs can also be created in the production environment, which
    communicates with the administration's production environment. These are the ones taken into account for billing.

    &nbsp;

    When a new NIF is added, it is in "active" status and can be used to make calls to the administration.
    At any time, a NIF can be activated or deactivated using the corresponding endpoint. Deactivated NIFs remain
    stored in our system and will no longer be charged for. They can be activated at any time to continue sending invoices
    to the tax agency on their behalf.
- name: Validation
  description: |2

    There are many circumstances where it is useful to validate that a NIF is correct and registered with the administration, for both
    companies (CIF) and national citizens (DNI) and foreign residents (NIE). For this purpose, we provide a specific endpoint that allows
    checking the status of a NIF with the administration.

    Additionally, we provide an endpoint to check the validity of intra-community VAT numbers in the VIES census.

    &nbsp;

    These validation endpoints are the only ones that can be used with a NIFs management API key (vfn_...) or a specific company key
    (vf_...).
- name: Representation
  description: |
    To generate and send invoices to the AEAT production environment using our API, it is necessary
    to fill out a representation grant form
    and <span style="font-weight: bold; text-decoration: underline">the invoice issuer NIF</span> must sign it digitally.
    This document was published in the resolution of December 18,
    2024 published in the BOE on December 31, 2024, which can be
    found <a target="_blank" href="https://www.boe.es/buscar/doc.php?id=BOE-A-2024-27600">here</a>.

    &nbsp;

    In this section we explain the steps to follow and how to do it through our API.

    <div style="margin-top: 32px; margin-bottom: 6px; font-size: 16px; font-weight: bold;">
      1. Fill in the PDF document data
    </div>

    <div style="margin-left: 18px;">
      The first step is to download the representation grant document in PDF format and fill it in. To do this,
      we provide the POST <code>/representacion/generar/{nif}</code> endpoint, which accepts the relevant data and returns the pre-filled PDF.
      It is possible to generate the PDF for a natural person or a legal entity.
    </div>

    <div style="margin-top: 32px; margin-bottom: 6px; font-size: 16px; font-weight: bold;">
      2. Sign the document using an electronic certificate
    </div>

    <div style="margin-left: 18px;">
      Once the PDF with the filled-in data is obtained, <span style="font-weight: bold; text-decoration: underline">the invoice issuer NIF</span> must sign it using an electronic certificate. For natural persons,
      a citizen certificate will be used, and for legal entities, an entity representative certificate will be used.
      These certificates are files in .p12 or .pfx format which, together with a password, allow documents to be electronically signed.
      If you do not have one, you can request it from various certification bodies such as
      the <a target="_blank" href="https://www.sede.fnmt.gob.es/">FNMT</a> or <a target="_blank" href="https://www.izenpe.eus/">Izenpe</a>.

      &nbsp;

      For the process of signing the PDF with the digital certificate, there are many possible options. At Verifacti we have chosen
      to create a simple program that can be downloaded for free and used to sign PDF documents electronically.
      It can be downloaded as a Windows executable or as a Python script.

      <div style="margin-top: 20px; margin-bottom: 6px; font-size: 14px; font-weight: bold;">
        a. Windows executable for signing
      </div>

      <div style="margin-left: 16px;">
        Download the Windows executable for signing PDF
        documents <a href="https://storage.googleapis.com/verifacti_non_sensitive/ejecutable.zip" download="ejecutable.zip" >here</a>.
        To use it, simply specify the path of the PDF to sign, the certificate path and its password.
        The result will be saved in the same folder as the original PDF with the suffix "_firmado.pdf".
      </div>

      <pre style="
        display: flex;
        margin-left: 16px;
        margin-top: 20px;
        margin-bottom: 20px;
        background-color: #212d63;
        max-width: fit-content;
        color: #ffffff;
        padding: 14px;
        border-radius: 0.25rem;
        overflow-x: auto;
      ">
        <code style="
          font-family: monospace;
          font-size: 0.875rem;
        ">./firmador.exe /ruta/pdf.pdf /ruta/certificado.pfx "contraseña"</code>
      </pre>

      <div style="margin-top: 20px; margin-bottom: 6px; font-size: 14px; font-weight: bold;">
        b. Python program for signing
      </div>

      <div style="margin-left: 16px;">
        You can download the Python program for signing PDF
        documents <a href="https://storage.googleapis.com/verifacti_non_sensitive/firmador.zip" download="firmador.zip" >here</a>.
        Usage instructions are described in the help file. Simply specify the path of the PDF to sign, the path where
        the certificate is located and its password. The result will be saved in the same folder as the original PDF with the suffix "_firmado.pdf".
      </div>

      <pre style="
        display: flex;
        margin-left: 16px;
        margin-top: 20px;
        margin-bottom: 20px;
        background-color: #212d63;
        max-width: fit-content;
        color: #ffffff;
        padding: 14px;
        border-radius: 0.25rem;
        overflow-x: auto;
      ">
        <code style="
          font-family: monospace;
          font-size: 0.875rem;
        ">firmador.py /ruta/pdf.pdf /ruta/certificado.pfx 'contraseña'</code>
      </pre>

      <div style="margin-top: 20px; margin-bottom: 6px; font-size: 14px; font-weight: bold;">
        c. Third-party applications
      </div>

      <div style="margin-left: 16px;">
        The most well-known application for signing PDF documents is <a href="https://get.adobe.com/es/reader/">Adobe Acrobat</a> which can be
        downloaded for free and used to electronically sign PDF documents. This program has a paid version
        but it is entirely possible to sign documents with the free version. In the left menu, select the
        <strong>Use a certificate</strong> option, as shown in the <a className="link" target="_blank" href="https://app.verifacti.com/public/adobe.png">image</a>.
      </div>

      &nbsp;

      <div style="margin-left: 16px;">
        You can also use the <a href="https://firmaelectronica.gob.es/ciudadanos/descargas">AutoFirma</a> program, created by
        the Government of Spain to facilitate the electronic signing of documents.
      </div>
    </div>

    <div style="margin-top: 32px; margin-bottom: 6px; font-size: 16px; font-weight: bold;">
      3. Upload the signed document to our platform
    </div>

    <div style="margin-left: 16px;">
      Once the signed PDF is obtained, it must be uploaded to our platform. To do this, we provide the POST
      <code>/representacion/enviar/{nif}</code> endpoint, which receives the signed PDF and returns the operation status. The signature is validated
      programmatically on our side and it is verified that the NIF in the document matches the NIF in the certificate. For legal
      entities, the representative's NIF is also validated.
    </div>
- name: Webhooks
  description: |
    Our platform supports webhooks to receive automatic notifications when a invoicing record is generated.
    This feature is designed to avoid constant API polling, allowing your system to be notified immediately and
    efficiently when the result is available.

    &nbsp;

    Each invoicing record is linked to a NIF, and webhooks can be configured
    to listen for events related to one or more NIFs. Likewise, a single NIF
    can be associated with multiple webhooks.

    &nbsp;

    The API provides endpoints to:
    <ul style="list-style: disc; margin-top: 6px; margin-bottom: 0px;">
      <li>Create new webhooks</li>
      <li>Query existing webhooks</li>
      <li>Modify their configuration</li>
      <li>Delete webhooks</li>
      <li>Associate and dissociate NIFs with webhooks</li>
    </ul>

    &nbsp;

    **Notification Signature**

    For additional security, a `secret` value can be defined when creating a webhook.
    This secret is used to generate a digital signature (HMAC with the SHA-256 algorithm)
    that is included in each notification, within the HTTP header `X-Webhook-Signature`.

    &nbsp;

    This signature allows the webhook receiver to verify that:
    <ul style="list-style: disc; margin-top: 6px; margin-bottom: 0px;">
      <li>The message was sent by our API</li>
      <li>The content was not modified during transmission</li>
    </ul>

    &nbsp;

    To verify the signature:
    <ol style="list-style: decimal; margin-top: 6px; margin-bottom: 0px;">
      <li>Obtain the exact body of the received message (unaltered).</li>
      <li>Use the same secret associated with the webhook to compute an HMAC-SHA256 signature (in hexadecimal).</li>
      <li>Compare the generated signature with the one in the `X-Webhook-Signature` header.</li>
    </ol>

    &nbsp;

    If both signatures match, you can trust that the message is authentic.

    &nbsp;

    **Idempotency Key**

    Each notification also includes an `X-Webhook-Id` header whose value is a unique identifier (UUID v4) generated by our API for that specific notification. This identifier is **stable across retries**: if a notification is retried, every attempt carries the same `X-Webhook-Id` value. We recommend using it as an idempotency key on your side to avoid processing the same notification twice.

    &nbsp;

    **Retries**

    If your endpoint responds with a non-`2xx` status code (or does not respond within the timeout), the notification is automatically retried with exponential backoff. The current policy is:

    <ul style="list-style: disc; margin-top: 6px; margin-bottom: 0px;">
      <li>Up to <strong>5 attempts</strong> total (1 initial delivery + 4 retries).</li>
      <li>Exponential backoff between <strong>30 seconds</strong> and <strong>1 hour</strong>.</li>
    </ul>

    &nbsp;

    After 5 attempts, the delivery is dropped.

    &nbsp;

    **Payload structure**

    The request body is a JSON array. Each element corresponds to the result that would be returned by the
    `Record Status` endpoint of the VeriFactu or TicketBai APIs, depending on the type of NIF. Some fields are
    only present on one of the two APIs; the `estado` field indicates whether error fields are applicable.
    A sample notification with two invoicing records is shown on the right.

    <SchemaDefinition schemaRef="#/components/schemas/WebhookNotification" />
paths:
  /nifs:
    get:
      summary: List NIFs
      tags:
      - NIFs
      description: |
        This endpoint returns a list of all NIFs. By default, it returns both active and inactive NIFs in both environments,
        but allows filtering by active or inactive status and environment.
      parameters:
      - in: query
        name: entorno
        schema:
          type: string
          enum:
          - test
          - prod
        description: Parameter to filter NIFs by environment. If not included, all NIFs will be returned.
        example: prod
      - in: query
        name: activos
        schema:
          type: boolean
        description: Parameter to filter active or inactive NIFs. If not included, all NIFs will be returned.
        example: true
      - in: query
        name: limite
        schema:
          type: integer
          maximum: 100
          minimum: 1
          default: 40
        description: Parameter to limit the number of NIFs returned. The default value is 40 and the maximum is 100.
        example: 50
      - in: query
        name: pagina
        schema:
          type: integer
          default: 1
        description: Parameter to paginate the NIF list.
        example: 3
      - in: query
        name: label
        schema:
          type: string
        description: |
          Parameter to filter NIFs by label. Only NIFs whose label exactly matches will be returned.

          The value must be URL-encoded (`encodeURIComponent` or equivalent), since labels can contain spaces or special characters (e.g. `Customer & Co` → `Customer%20%26%20Co`).
        example: Customer A
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/nifs?entorno=test&activos=true' \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs?entorno=test&activos=true'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.get(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs?entorno=test&activos=true';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.get("https://api.verifacti.com/nifs?entorno=test&activos=true", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs?entorno=test&activos=true";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"GET\", \"https://api.verifacti.com/nifs?entorno=test&activos=true\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs?entorno=test&activos=true"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .GET()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.GetAsync("https://api.verifacti.com/nifs?entorno=test&activos=true");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs?entorno=test&activos=true"

          oHttp.Open "GET", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          description: NIF list
          content:
            application/json:
              schema:
                type: array
                items:
                  properties:
                    nif:
                      description: NIF.
                      type: string
                    entorno:
                      description: NIF environment. Can be "test" or "prod".
                      type: string
                    hacienda:
                      description: |
                        Tax authority the NIF is linked to. The possible values are:
                        <ol style="list-style-type: disc">
                          <li>verifactu</li>
                          <li>alava</li>
                          <li>guipuzcoa</li>
                          <li>vizcaya</li>
                        </ol>
                      type: string
                    nombre:
                      description: Full name or company name of the NIF.
                      type: string
                    activo:
                      description: Indicates whether the NIF is active or not.
                      type: boolean
                    representacion:
                      enum:
                      - Correcto
                      - Rechazado
                      - Inexistente
                      description: |
                        Indicates the status of the NIF's representation model. The possible values are:
                        <ol style="list-style-type: disc">
                          <li>Correcto: The representation model has been received and validated correctly.</li>
                          <li>Rechazado: The representation model has been received but could not be validated.</li>
                          <li>Inexistente: The signed representation model has not been received.</li>
                        </ol>

                        This field is only present for VeriFactu NIFs. For production NIFs, the representation status must be
                        "Correcto" in order to send invoices.
                      type: string
                    fecha_creacion:
                      description: NIF creation date.
                      type: string
                    webhooks:
                      description: List of webhook identifiers associated with the NIF.
                      type: array
                      items:
                        type: string
                    label:
                      description: Label associated with the NIF. May be `null` if none has been assigned.
                      type: string
                    pagado_hasta:
                      type: string
                      description: |
                        Field only available for production NIFs, as these are the only ones that require payment.
                        This field indicates the date until which the NIF has been paid for. If the NIF is active on that date,
                        it will be renewed automatically and the date will be updated automatically.
                example:
                - nif: B86561412
                  entorno: test
                  hacienda: verifactu
                  nombre: Mi empresa SL
                  activo: true
                  fecha_creacion: "2024-12-01T12:18:21.671Z"
                  representacion: Inexistente
                  webhooks:
                  - 17067405-8c32-4efe-a7cb-8fad93403997
                  label: Customer A
                - nif: C01345232
                  entorno: test
                  hacienda: alava
                  nombre: Mi empresa 2 SL
                  activo: true
                  fecha_creacion: "2025-01-01T09:08:41.645Z"
                  representacion: Correcto
                  webhooks: []
                  label: null
        "400":
          description: Invalid query parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
    post:
      summary: Add NIFs
      tags:
      - NIFs
      description: |
        This endpoint adds new NIFs.

        &nbsp;

        To activate a NIF that has been previously deactivated, the corresponding endpoint should be used
        instead of creating a new one. If attempted, a 409 error will be returned.

        &nbsp;

        <span style="color: red">IMPORTANT</span>: For annual subscriptions, when adding new NIFs in the production environment,
        the corresponding amount will be charged immediately and a new invoice will be generated that can be viewed on our platform,
        in the billing section. To avoid generating multiple invoices, several NIFs can be added at once and they will all be charged together.
        For monthly subscriptions, the corresponding amount for the new NIFs will be charged on the next monthly invoice.

        &nbsp;

        `test` type NIFs will not be counted for billing.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl --request POST 'https://api.verifacti.com/nifs' \
          --header 'Authorization: Bearer <USER_API_KEY>' \
          --header 'Content-Type: application/json' \
          --data-raw '[
            {
              "nif": "B86561412",
              "entorno": "test",
              "hacienda": "verifactu",
              "nombre": "Mi empresa SL",
              "direccion": "Calle Mayor 15",
              "cp": "28040",
              "poblacion": "Madrid",
              "provincia": "Madrid"
            },
            {
              "nif": "B01345232",
              "entorno": "prod",
              "hacienda": "verifactu",
              "nombre": "Mi otra empresa SL",
              "direccion": "Gran Vía 22",
              "cp": "28040",
              "poblacion": "Madrid",
              "provincia": "Madrid"
            }
          ]'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>',
            'Content-Type': 'application/json'
          }
          data = [
            {
              'nif': 'B86561412',
              'entorno': 'test',
              'hacienda': 'verifactu',
              'nombre': 'Mi empresa SL',
              'direccion': 'Calle Mayor 15',
              'cp': '28040',
              'poblacion': 'Madrid',
              'provincia': 'Madrid'
            },
            {
              'nif': 'B01345232',
              'entorno': 'prod',
              'hacienda': 'verifactu',
              'nombre': 'Mi otra empresa SL',
              'direccion': 'Gran Vía 22',
              'cp': '28040',
              'poblacion': 'Madrid',
              'provincia': 'Madrid'
            }
          ]
          response = requests.post(url, headers=headers, json=data)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>',
            'Content-Type': 'application/json'
          };
          const data = [
            {
              'nif': 'B86561412',
              'entorno': 'test',
              'hacienda': 'verifactu',
              'nombre': 'Mi empresa SL',
              'direccion': 'Calle Mayor 15',
              'cp': '28040',
              'poblacion': 'Madrid',
              'provincia': 'Madrid'
            },
            {
              'nif': 'B01345232',
              'entorno': 'prod',
              'hacienda': 'verifactu',
              'nombre': 'Mi otra empresa SL',
              'direccion': 'Gran Vía 22',
              'cp': '28040',
              'poblacion': 'Madrid',
              'provincia': 'Madrid'
            }
          ]
          fetch(url, { headers, method: 'POST', body: JSON.stringify(data) })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const data = [
            {
              "nif": "B86561412",
              "entorno": "test",
              "hacienda": "verifactu",
              "nombre": "Mi empresa SL",
              "direccion": "Calle Mayor 15",
              "cp": "28040",
              "poblacion": "Madrid",
              "provincia": "Madrid"
            },
            {
              "nif": "B01345232",
              "entorno": "prod",
              "hacienda": "verifactu",
              "nombre": "Mi otra empresa SL",
              "direccion": "Gran Vía 22",
              "cp": "28040",
              "poblacion": "Madrid",
              "provincia": "Madrid"
            }
          ];

          const response = await axios.post("https://api.verifacti.com/nifs", data, {
            headers: {
              "Authorization": "Bearer <API_KEY>",
              "Content-Type": "application/json"
            }
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs";

          $headers = [
              "Authorization: Bearer <API_KEY>",
              "Content-Type: application/json"
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $body = <<<'JSON'
          [
            {
              "nif": "B86561412",
              "entorno": "test",
              "hacienda": "verifactu",
              "nombre": "Mi empresa SL",
              "direccion": "Calle Mayor 15",
              "cp": "28040",
              "poblacion": "Madrid",
              "provincia": "Madrid"
            },
            {
              "nif": "B01345232",
              "entorno": "prod",
              "hacienda": "verifactu",
              "nombre": "Mi otra empresa SL",
              "direccion": "Gran Vía 22",
              "cp": "28040",
              "poblacion": "Madrid",
              "provincia": "Madrid"
            }
          ]
          JSON;

          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"strings\"\n)\n\nfunc main() {\n\tbody := `\n[\n  {\n    \"nif\": \"B86561412\",\n    \"entorno\": \"test\",\n    \"hacienda\": \"verifactu\",\n    \"nombre\": \"Mi empresa SL\",\n    \"direccion\": \"Calle Mayor 15\",\n    \"cp\": \"28040\",\n    \"poblacion\": \"Madrid\",\n    \"provincia\": \"Madrid\"\n  },\n  {\n    \"nif\": \"B01345232\",\n    \"entorno\": \"prod\",\n    \"hacienda\": \"verifactu\",\n    \"nombre\": \"Mi otra empresa SL\",\n    \"direccion\": \"Gran Vía 22\",\n    \"cp\": \"28040\",\n    \"poblacion\": \"Madrid\",\n    \"provincia\": \"Madrid\"\n  }\n]\n`\n\n\treq, err := http.NewRequest(\"POST\", \"https://api.verifacti.com/nifs\", strings.NewReader(body))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  String body = """
                          [
                            {
                              "nif": "B86561412",
                              "entorno": "test",
                              "hacienda": "verifactu",
                              "nombre": "Mi empresa SL",
                              "direccion": "Calle Mayor 15",
                              "cp": "28040",
                              "poblacion": "Madrid",
                              "provincia": "Madrid"
                            },
                            {
                              "nif": "B01345232",
                              "entorno": "prod",
                              "hacienda": "verifactu",
                              "nombre": "Mi otra empresa SL",
                              "direccion": "Gran Vía 22",
                              "cp": "28040",
                              "poblacion": "Madrid",
                              "provincia": "Madrid"
                            }
                          ]
                          """;

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .header("Content-Type", "application/json")
                      .POST(HttpRequest.BodyPublishers.ofString(body))
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var body = @"
                      [
            {
              ""nif"": ""B86561412"",
              ""entorno"": ""test"",
              ""hacienda"": ""verifactu"",
              ""nombre"": ""Mi empresa SL"",
              ""direccion"": ""Calle Mayor 15"",
              ""cp"": ""28040"",
              ""poblacion"": ""Madrid"",
              ""provincia"": ""Madrid""
            },
            {
              ""nif"": ""B01345232"",
              ""entorno"": ""prod"",
              ""hacienda"": ""verifactu"",
              ""nombre"": ""Mi otra empresa SL"",
              ""direccion"": ""Gran Vía 22"",
              ""cp"": ""28040"",
              ""poblacion"": ""Madrid"",
              ""provincia"": ""Madrid""
            }
          ]
                  ";

                  var content = new StringContent(body, Encoding.UTF8, "application/json");

                  var response = await client.PostAsync("https://api.verifacti.com/nifs", content);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs"

          oHttp.Open "POST", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"
          oHttp.setRequestHeader "Content-Type", "application/json"

          Dim sBody As String
          sBody = "[" & vbCrLf & _
                 "  {" & vbCrLf & _
                 "    ""nif"": ""B86561412""," & vbCrLf & _
                 "    ""entorno"": ""test""," & vbCrLf & _
                 "    ""hacienda"": ""verifactu""," & vbCrLf & _
                 "    ""nombre"": ""Mi empresa SL""," & vbCrLf & _
                 "    ""direccion"": ""Calle Mayor 15""," & vbCrLf & _
                 "    ""cp"": ""28040""," & vbCrLf & _
                 "    ""poblacion"": ""Madrid""," & vbCrLf & _
                 "    ""provincia"": ""Madrid""" & vbCrLf & _
                 "  }," & vbCrLf & _
                 "  {" & vbCrLf & _
                 "    ""nif"": ""B01345232""," & vbCrLf & _
                 "    ""entorno"": ""prod""," & vbCrLf & _
                 "    ""hacienda"": ""verifactu""," & vbCrLf & _
                 "    ""nombre"": ""Mi otra empresa SL""," & vbCrLf & _
                 "    ""direccion"": ""Gran Vía 22""," & vbCrLf & _
                 "    ""cp"": ""28040""," & vbCrLf & _
                 "    ""poblacion"": ""Madrid""," & vbCrLf & _
                 "    ""provincia"": ""Madrid""" & vbCrLf & _
                 "  }" & vbCrLf & _
                 "]"

          oHttp.send sBody

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      requestBody:
        content:
          application/json:
            schema:
              type: array
              minItems: 1
              maxItems: 400
              items:
                type: object
                required:
                - nif
                - entorno
                - nombre
                properties:
                  nif:
                    description: |
                      NIF. There cannot be duplicates in the NIF array. NIFs that have been previously added cannot be added again,
                      even if they are deactivated. Finally, the NIF format will be verified, but not whether the NIF is
                      registered at the tax agency. A specific endpoint is available for this and it is recommended to do so before trying to
                      add a NIF.
                    type: string
                  nombre:
                    description: Full name or company name of the NIF.
                    type: string
                  entorno:
                    description: |
                      Environment the NIF is linked to. The possible values are:
                      <ol style="list-style-type: disc">
                        <li>test: used to send invoices to the administration's test environment and are free.</li>
                        <li>
                          prod: used to send invoices to the administration's production environment and the
                          corresponding amount will be charged at creation time.
                        </li>
                      </ol>
                    type: string
                    enum:
                    - test
                    - prod
                  hacienda:
                    description: |
                      Tax authority the NIF will be linked to. If not included, `verifactu` will be assumed. The possible values are:
                      <ol style="list-style-type: disc">
                        <li>verifactu</li>
                        <li>alava</li>
                        <li>guipuzcoa</li>
                        <li>vizcaya</li>
                      </ol>
                    type: string
                    default: verifactu
                  validar_nif:
                    description: |
                      Optional parameter. Indicates whether to validate that the NIF is registered with the administration before adding it.
                      By default it is `true` and if an attempt is made to add an unregistered NIF, a 400 error will be returned.
                      This option can be disabled when `entorno=test` to register unregistered NIFs for testing. The administration will not accept
                      invoices sent from unregistered NIFs, even in the test environment.
                    type: boolean
                    default: true
                  webhooks:
                    description: |
                      Optional parameter. List of webhook identifiers to which the NIF will be linked.
                    type: array
                    items:
                      type: string
                  label:
                    description: Optional parameter. Label associated with the NIF for organization and filtering.
                    type: string
                  direccion:
                    description: NIF address.
                    type: string
                  cp:
                    description: NIF postal code.
                    type: string
                  poblacion:
                    description: NIF city.
                    type: string
                  provincia:
                    description: NIF province.
                    type: string
                  persona_fisica:
                    description: |
                      Only allowed for Vizcaya. Indicates whether the NIF must submit model 140 (`true`) or model 240 (`false`).
                      In the Batuz system, model 140 is for individuals (self-employed), joint ownerships, and civil partnerships
                      (autónomos, comunidades de bienes y sociedades civiles).
                      When sending invoices under model 140, the `detalle_renta` field must be included.
                      By default, it is `false`.
                    type: boolean
                    default: false
              example:
              - nif: B86561412
                entorno: test
                hacienda: verifactu
                nombre: Mi empresa SL
                direccion: Calle Mayor 15
                cp: "28040"
                poblacion: Madrid
                provincia: Madrid
              - nif: B01345232
                entorno: prod
                hacienda: verifactu
                nombre: Mi otra empresa SL
                direccion: Gran Vía 22
                cp: "28040"
                poblacion: Madrid
                provincia: Madrid
      responses:
        "200":
          description: NIF
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    nif:
                      description: NIF.
                      type: string
                    nombre:
                      description: Full name or company name of the NIF.
                      type: string
                    activo:
                      description: Indicates whether the NIF is active or not.
                      type: boolean
                    direccion:
                      description: NIF address.
                      type: string
                    cp:
                      description: NIF postal code.
                      type: string
                    poblacion:
                      description: NIF city.
                      type: string
                    provincia:
                      description: NIF province.
                      type: string
                    fecha_creacion:
                      description: NIF creation date.
                      type: string
                    fecha_modificacion:
                      description: Date of the last NIF modification.
                      type: string
                example:
                - nif: B86561412
                  nombre: Mi empresa SL
                  hacienda: verifactu
                  webhooks: []
                  activo: true
                  direccion: Calle Mayor 15
                  cp: "28040"
                  poblacion: Madrid
                  provincia: Madrid
                  fecha_creacion: "2025-01-12T00:00:00.000Z"
                  fecha_modificacion: "2025-12-01T00:00:00.000Z"
                - nif: B01345232
                  nombre: Mi otra empresa SL
                  hacienda: verifactu
                  webhooks: []
                  activo: true
                  direccion: Gran Vía 22
                  cp: "28040"
                  poblacion: Madrid
                  provincia: Madrid
                  fecha_creacion: "2025-01-12T00:00:00.000Z"
                  fecha_modificacion: "2025-12-01T00:00:00.000Z"
        "400":
          description: Invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "409":
          description: NIF already exists
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /nifs/{entorno}/{nif}:
    get:
      summary: NIF Information
      tags:
      - NIFs
      parameters:
      - in: path
        name: entorno
        schema:
          type: string
          enum:
          - test
          - prod
        required: true
        description: NIF environment
        example: test
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF
        example: B86561412
      description: This endpoint returns the information of a specific NIF.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/nifs/test/B86561412' \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs/test/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.get(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs/test/B86561412';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.get("https://api.verifacti.com/nifs/test/B86561412", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs/test/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"GET\", \"https://api.verifacti.com/nifs/test/B86561412\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs/test/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .GET()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.GetAsync("https://api.verifacti.com/nifs/test/B86561412");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs/test/B86561412"

          oHttp.Open "GET", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          $ref: "#/components/responses/nifResponse"
        "404":
          description: NIF not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
    put:
      summary: Modify NIF
      tags:
      - NIFs
      parameters:
      - in: path
        name: entorno
        schema:
          type: string
          enum:
          - test
          - prod
        required: true
        description: NIF environment
        example: test
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF
        example: B86561412
      description: This endpoint allows modifying the information of a specific NIF.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl --request PUT 'https://api.verifacti.com/nifs/test/B86561412' \
          --header 'Authorization: Bearer <USER_API_KEY>' \
          --header 'Content-Type: application/json' \
          --data-raw '{
            "nombre": "Mi empresa SL",
            "webhooks": ["17067405-8c32-4efe-a7cb-8fad93403997"],
            "direccion": "Calle Mayor 15",
            "cp": "28040",
            "poblacion": "Madrid",
            "provincia": "Madrid",
          }'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs/test/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>',
            'Content-Type': 'application/json'
          }
          data = {
            'nombre': 'Mi empresa SL',
            'webhooks': ['17067405-8c32-4efe-a7cb-8fad93403997'],
            'direccion': 'Calle Mayor 15',
            'cp': '28040',
            'poblacion': 'Madrid',
            'provincia': 'Madrid',
          }
          response = requests.put(url, headers=headers, json=data)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs/test/B86561412';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>',
            'Content-Type': 'application/json'
          };
          const data = {
            'nombre': 'Mi empresa SL',
            'webhooks': ['17067405-8c32-4efe-a7cb-8fad93403997'],
            'direccion': 'Calle Mayor 15',
            'cp': '28040',
            'poblacion': 'Madrid',
            'provincia': 'Madrid',
          };
          fetch(url, { headers, method: 'PUT', body: JSON.stringify(data) })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const data = {
            'nombre': 'Mi empresa SL',
            'webhooks': ['17067405-8c32-4efe-a7cb-8fad93403997'],
            'direccion': 'Calle Mayor 15',
            'cp': '28040',
            'poblacion': 'Madrid',
            'provincia': 'Madrid',
          };

          const response = await axios.put("https://api.verifacti.com/nifs/test/B86561412", data, {
            headers: {
              "Authorization": "Bearer <API_KEY>",
              "Content-Type": "application/json"
            }
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs/test/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
              "Content-Type: application/json"
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $body = <<<'JSON'
          {
            "nombre": "Mi empresa SL",
            "webhooks": ["17067405-8c32-4efe-a7cb-8fad93403997"],
            "direccion": "Calle Mayor 15",
            "cp": "28040",
            "poblacion": "Madrid",
            "provincia": "Madrid",
          }
          JSON;

          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"strings\"\n)\n\nfunc main() {\n\tbody := `\n{\n  \"nombre\": \"Mi empresa SL\",\n  \"webhooks\": [\"17067405-8c32-4efe-a7cb-8fad93403997\"],\n  \"direccion\": \"Calle Mayor 15\",\n  \"cp\": \"28040\",\n  \"poblacion\": \"Madrid\",\n  \"provincia\": \"Madrid\",\n}\n`\n\n\treq, err := http.NewRequest(\"PUT\", \"https://api.verifacti.com/nifs/test/B86561412\", strings.NewReader(body))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  String body = """
                          {
                            "nombre": "Mi empresa SL",
                            "webhooks": ["17067405-8c32-4efe-a7cb-8fad93403997"],
                            "direccion": "Calle Mayor 15",
                            "cp": "28040",
                            "poblacion": "Madrid",
                            "provincia": "Madrid",
                          }
                          """;

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs/test/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .header("Content-Type", "application/json")
                      .PUT(HttpRequest.BodyPublishers.ofString(body))
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var body = @"
                      {
            ""nombre"": ""Mi empresa SL"",
            ""webhooks"": [""17067405-8c32-4efe-a7cb-8fad93403997""],
            ""direccion"": ""Calle Mayor 15"",
            ""cp"": ""28040"",
            ""poblacion"": ""Madrid"",
            ""provincia"": ""Madrid"",
          }
                  ";

                  var content = new StringContent(body, Encoding.UTF8, "application/json");

                  var response = await client.PutAsync("https://api.verifacti.com/nifs/test/B86561412", content);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs/test/B86561412"

          oHttp.Open "PUT", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"
          oHttp.setRequestHeader "Content-Type", "application/json"

          Dim sBody As String
          sBody = "{" & vbCrLf & _
                 "  ""nombre"": ""Mi empresa SL""," & vbCrLf & _
                 "  ""webhooks"": [""17067405-8c32-4efe-a7cb-8fad93403997""]," & vbCrLf & _
                 "  ""direccion"": ""Calle Mayor 15""," & vbCrLf & _
                 "  ""cp"": ""28040""," & vbCrLf & _
                 "  ""poblacion"": ""Madrid""," & vbCrLf & _
                 "  ""provincia"": ""Madrid""," & vbCrLf & _
                 "}"

          oHttp.send sBody

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                nombre:
                  description: Full name or company name of the NIF.
                  type: string
                  example: Mi empresa SL
                direccion:
                  description: NIF address.
                  type: string
                  example: Calle Mayor 15
                cp:
                  description: NIF postal code.
                  type: string
                  example: "28040"
                poblacion:
                  description: NIF city.
                  type: string
                  example: Madrid
                provincia:
                  description: NIF province.
                  type: string
                  example: Madrid
                webhooks:
                  description: |
                    List of webhook identifiers to which the NIF will be linked.
                  type: array
                  items:
                    type: string
                    example: 17067405-8c32-4efe-a7cb-8fad93403997
                label:
                  description: Label associated with the NIF. Sending an empty string clears the existing label.
                  type: string
                  example: Customer A
      responses:
        "200":
          $ref: "#/components/responses/nifResponse"
        "400":
          description: Invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "404":
          description: NIF not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
    delete:
      summary: Deactivate NIF
      tags:
      - NIFs
      parameters:
      - in: path
        name: entorno
        schema:
          type: string
          enum:
          - test
          - prod
        required: true
        description: NIF environment
        example: test
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF
        example: B86561412
      description: |
        This endpoint allows deactivating a NIF. This means that calls to our API to send invoices
        to the corresponding tax authority for the deactivated NIF will no longer be possible.

        Charges for the deactivated NIF will stop if it is a NIF in the production environment. Any deactivated NIF
        can be reactivated at any time to continue sending invoices to the corresponding tax authority.

        &nbsp;

        <span style="color: red">IMPORTANT</span>: When deactivating a NIF, <u><strong>the invoicing records will be deleted</strong></u> for that NIF 30 days after deactivation.
        If reactivated before that period, the invoicing records will not be lost. Even if the billing data is deleted, the NIF can be reactivated
        at any time and invoices can be sent without breaking the chain. Remember that XML export endpoints exist in case you want to
        preserve the billing data.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/nifs/test/B86561412' \
          --request DELETE \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs/test/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.delete(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs/test/B86561412';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers, method: 'DELETE' })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.delete("https://api.verifacti.com/nifs/test/B86561412", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs/test/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"DELETE\", \"https://api.verifacti.com/nifs/test/B86561412\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs/test/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .DELETE()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.DeleteAsync("https://api.verifacti.com/nifs/test/B86561412");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs/test/B86561412"

          oHttp.Open "DELETE", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          $ref: "#/components/responses/okResponse"
        "403":
          description: NIF is already inactive
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "404":
          description: NIF not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /nifs/{entorno}/{nif}/permanent:
    delete:
      summary: Delete NIF
      tags:
      - NIFs
      parameters:
      - in: path
        name: entorno
        schema:
          type: string
          enum:
          - test
          - prod
        required: true
        description: NIF environment
        example: test
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF
        example: B86561412
      description: |
        This endpoint allows <u><strong>permanently</strong></u> deleting a NIF. All information associated with the NIF will be deleted, including invoicing records,
        immediately and permanently. This does not include the representation model.

        &nbsp;

        Charges for the deleted NIF will stop if it is a NIF in the production environment. Any deleted NIF
        cannot be reactivated or used to send invoices to the corresponding tax authority. However, the NIF can be created again
        but it will be treated as a completely new NIF. This new NIF will have its own billing chain independent of the deleted NIF.

        &nbsp;

        <span style="color: red">IMPORTANT</span>: When deleting a NIF, the associated <u><strong>invoicing records will be deleted</strong></u>.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/nifs/test/B86561412/permanent' \
          --request DELETE \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs/test/B86561412/permanent'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.delete(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs/test/B86561412/permanent';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers, method: 'DELETE' })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.delete("https://api.verifacti.com/nifs/test/B86561412/permanent", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs/test/B86561412/permanent";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"DELETE\", \"https://api.verifacti.com/nifs/test/B86561412/permanent\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs/test/B86561412/permanent"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .DELETE()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.DeleteAsync("https://api.verifacti.com/nifs/test/B86561412/permanent");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs/test/B86561412/permanent"

          oHttp.Open "DELETE", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          $ref: "#/components/responses/okResponse"
        "404":
          description: NIF not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /nifs/activate/{entorno}/{nif}:
    put:
      summary: Activate NIF
      tags:
      - NIFs
      parameters:
      - in: path
        name: entorno
        schema:
          type: string
          enum:
          - test
          - prod
        required: true
        description: NIF environment
        example: test
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF
        example: B86561412
      description: |
        This endpoint allows activating a NIF that has been previously deactivated.

        &nbsp;

        <span style="color: red">IMPORTANT</span>: When activating a production NIF whose `pagado_hasta` date is before the current date,
        the corresponding amount will be charged immediately and the corresponding invoice will be generated.
        This can be viewed on the platform, in the billing section. For those production NIFs whose `pagado_hasta` date
        is after the current date, nothing will be charged, as payment has already been made for the current period.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/nifs/activate/test/B86561412' \
          --request PUT \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs/activate/test/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.put(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs/activate/test/B86561412';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers, method: 'PUT' })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.put("https://api.verifacti.com/nifs/activate/test/B86561412", null, {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs/activate/test/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"PUT\", \"https://api.verifacti.com/nifs/activate/test/B86561412\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs/activate/test/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .PUT(HttpRequest.BodyPublishers.noBody())
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.PutAsync("https://api.verifacti.com/nifs/activate/test/B86561412", null);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs/activate/test/B86561412"

          oHttp.Open "PUT", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          $ref: "#/components/responses/okResponse"
        "403":
          description: NIF is already active
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "404":
          description: NIF not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /nifs/keys/{entorno}/{nif}:
    get:
      summary: NIF API Key
      tags:
      - NIFs
      parameters:
      - in: path
        name: entorno
        schema:
          type: string
          enum:
          - test
          - prod
        required: true
        description: Environment
        example: test
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF
        example: B86561412
      description: |
        This endpoint returns the API key for a specific NIF in a specific environment. With this API key, calls can be made to our VeriFactu or TicketBai API,
        as applicable, to send invoices to the tax agency. If the NIF is deactivated, a 404 error is returned.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/nifs/keys/test/B86561412' \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs/keys/test/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.get(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs/keys/test/B86561412';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.get("https://api.verifacti.com/nifs/keys/test/B86561412", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs/keys/test/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"GET\", \"https://api.verifacti.com/nifs/keys/test/B86561412\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs/keys/test/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .GET()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.GetAsync("https://api.verifacti.com/nifs/keys/test/B86561412");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs/keys/test/B86561412"

          oHttp.Open "GET", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          description: API key
          content:
            application/json:
              schema:
                type: object
                properties:
                  api_key:
                    description: API key for the corresponding NIF and environment.
                    type: string
                    example: B86561412
        "404":
          description: NIF not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /nifs/validar:
    post:
      summary: Validate NIF at the AEAT
      tags:
      - Validation
      description: |
        This endpoint validates whether a NIF of an individual or legal entity is identified at the tax agency. This endpoint
        performs a query to the service that the tax agency provides for this purpose.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
              - nif
              properties:
                nif:
                  description: NIF of the individual or legal entity to be verified.
                  type: string
                  example: B86561412
                nombre:
                  type: string
                  example: Mi empresa SL
                  description: |
                    Last name and first name of the individual or company name of the legal entity for which
                    the verification query is to be made. Required for individuals. Optional for legal entities.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/nifs/validar' \
          --request POST \
          --header 'Authorization: Bearer <USER_API_KEY>' \
          --data-raw '{"nif": "B86561412", "nombre": "Mi empresa SL"}'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs/validar'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          data = {
            'nif': 'B86561412',
            'nombre': 'Mi empresa SL'
          }
          response = requests.post(url, headers=headers, json=data)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs/validar';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          const data = {
            'nif': 'B86561412',
            'nombre': 'Mi empresa SL'
          };
          fetch(url, { headers, method: 'POST', body: JSON.stringify(data) })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const data = {
            'nif': 'B86561412',
            'nombre': 'Mi empresa SL'
          };

          const response = await axios.post("https://api.verifacti.com/nifs/validar", data, {
            headers: {
              "Authorization": "Bearer <API_KEY>",
              "Content-Type": "application/json"
            }
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs/validar";

          $headers = [
              "Authorization: Bearer <API_KEY>",
              "Content-Type: application/json"
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $body = <<<'JSON'
          {"nif": "B86561412", "nombre": "Mi empresa SL"}
          JSON;

          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"strings\"\n)\n\nfunc main() {\n\tbody := `\n{\"nif\": \"B86561412\", \"nombre\": \"Mi empresa SL\"}\n`\n\n\treq, err := http.NewRequest(\"POST\", \"https://api.verifacti.com/nifs/validar\", strings.NewReader(body))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  String body = """
                          {"nif": "B86561412", "nombre": "Mi empresa SL"}
                          """;

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs/validar"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .header("Content-Type", "application/json")
                      .POST(HttpRequest.BodyPublishers.ofString(body))
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var body = @"
                      {""nif"": ""B86561412"", ""nombre"": ""Mi empresa SL""}
                  ";

                  var content = new StringContent(body, Encoding.UTF8, "application/json");

                  var response = await client.PostAsync("https://api.verifacti.com/nifs/validar", content);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs/validar"

          oHttp.Open "POST", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"
          oHttp.setRequestHeader "Content-Type", "application/json"

          Dim sBody As String
          sBody = "{""nif"": ""B86561412"", ""nombre"": ""Mi empresa SL""}"

          oHttp.send sBody

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          description: AEAT response
          content:
            application/json:
              schema:
                type: object
                properties:
                  nif:
                    description: NIF of the individual or legal entity being queried.
                    type: string
                    example: B86561412
                  nombre:
                    description: Last name and first name or company name of the NIF of the individual or legal entity.
                    type: string
                    example: Mi empresa SL
                  resultado:
                    type: string
                    example: IDENTIFICADO
                    description: |
                      Indicates whether the NIF is identified or not. For individuals, there are three
                      possible cases:
                        <ol style="list-style-type: disc">
                          <li>
                            IDENTIFICADO: The taxpayer is identified with the provided identification data.
                            The last name and first name associated with the NIF are returned.
                          </li>
                          <li>
                            NO IDENTIFICADO-SIMILAR: The taxpayer is not identified with the provided identification data
                            due to minor differences in the last name and first name. The last name and first name
                            associated with the NIF are returned.
                          </li>
                          <li>
                            NO IDENTIFICADO: The taxpayer is not identified with the provided identification data.
                          </li>
                        </ol>

                      For entities, the NO IDENTIFICADO-SIMILAR result does not exist, but these two results are added:
                        <ol style="list-style-type: disc">
                          <li>
                            IDENTIFICADO-BAJA: The taxpayer is identified with the provided NIF and is in a deregistered
                            state. The current NIF and its company name are returned.
                          </li>
                          <li>
                            IDENTIFICADO-REVOCADO: The taxpayer is identified with the provided NIF and is in a
                            deregistered state due to NIF revocation. The current NIF and its company name are returned.
                          </li>
                        </ol>
        "400":
          description: Invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          description: Internal server error or AEAT service unavailable
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /nifs/validar_lotes:
    post:
      summary: Batch Validate NIFs
      tags:
      - Validation
      description: |
        This endpoint allows validating up to 20,000 NIFs in a single call, checking whether each NIF of an individual or legal entity exists.
      requestBody:
        content:
          application/json:
            schema:
              type: array
              minItems: 1
              maxItems: 20000
              items:
                type: object
                description: Each element in the array follows the format described in the validate NIF at the AEAT endpoint.
              example:
              - nif: B86561412
                nombre: Mi empresa SL
              - nif: C01345232
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/nifs/validar_lotes' \
          --request POST \
          --header 'Authorization: Bearer <USER_API_KEY>' \
          --data-raw '[{"nif": "B86561412", "nombre": "Mi empresa SL"}, {"nif": "C01345232"}]'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs/validar_lotes'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          data = [
            {'nif': 'B86561412', 'nombre': 'Mi empresa SL'},
            {'nif': 'C01345232'}
          ]
          response = requests.post(url, headers=headers, json=data)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs/validar_lotes';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          const data = [
            {'nif': 'B86561412', 'nombre': 'Mi empresa SL'},
            {'nif': 'C01345232'}
          ];
          fetch(url, { headers, method: 'POST', body: JSON.stringify(data) })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const data = [
            {'nif': 'B86561412', 'nombre': 'Mi empresa SL'},
            {'nif': 'C01345232'}
          ];

          const response = await axios.post("https://api.verifacti.com/nifs/validar_lotes", data, {
            headers: {
              "Authorization": "Bearer <API_KEY>",
              "Content-Type": "application/json"
            }
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs/validar_lotes";

          $headers = [
              "Authorization: Bearer <API_KEY>",
              "Content-Type: application/json"
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $body = <<<'JSON'
          [{"nif": "B86561412", "nombre": "Mi empresa SL"}, {"nif": "C01345232"}]
          JSON;

          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"strings\"\n)\n\nfunc main() {\n\tbody := `\n[{\"nif\": \"B86561412\", \"nombre\": \"Mi empresa SL\"}, {\"nif\": \"C01345232\"}]\n`\n\n\treq, err := http.NewRequest(\"POST\", \"https://api.verifacti.com/nifs/validar_lotes\", strings.NewReader(body))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  String body = """
                          [{"nif": "B86561412", "nombre": "Mi empresa SL"}, {"nif": "C01345232"}]
                          """;

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs/validar_lotes"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .header("Content-Type", "application/json")
                      .POST(HttpRequest.BodyPublishers.ofString(body))
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var body = @"
                      [{""nif"": ""B86561412"", ""nombre"": ""Mi empresa SL""}, {""nif"": ""C01345232""}]
                  ";

                  var content = new StringContent(body, Encoding.UTF8, "application/json");

                  var response = await client.PostAsync("https://api.verifacti.com/nifs/validar_lotes", content);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs/validar_lotes"

          oHttp.Open "POST", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"
          oHttp.setRequestHeader "Content-Type", "application/json"

          Dim sBody As String
          sBody = "[{""nif"": ""B86561412"", ""nombre"": ""Mi empresa SL""}, {""nif"": ""C01345232""}]"

          oHttp.send sBody

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          description: AEAT response
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    nif:
                      description: NIF of the individual or legal entity being queried.
                      type: string
                      example: B86561412
                    nombre:
                      description: Last name and first name or company name of the NIF of the individual or legal entity.
                      type: string
                      example: Mi empresa SL
                    resultado:
                      type: string
                      example: IDENTIFICADO
                      enum:
                        - IDENTIFICADO
                        - NO IDENTIFICADO
                        - NO IDENTIFICADO-SIMILAR
                        - IDENTIFICADO-BAJA
                        - IDENTIFICADO-REVOCADO
                        - ERROR
                      description: |
                        Indicates whether the NIF is identified or not. Possible values are:
                        <ol style="list-style-type: disc">
                          <li>IDENTIFICADO: The NIF is identified with the provided data.</li>
                          <li>NO IDENTIFICADO: The NIF is not identified.</li>
                          <li>NO IDENTIFICADO-SIMILAR: The NIF is not identified due to minor differences (individuals only).</li>
                          <li>IDENTIFICADO-BAJA: The NIF is identified but deregistered (entities only).</li>
                          <li>IDENTIFICADO-REVOCADO: The NIF is identified but revoked (entities only).</li>
                          <li>ERROR: Could not obtain the result for this NIF.</li>
                        </ol>
        "400":
          description: Invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          description: Internal server error or AEAT service unavailable
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /nifs/validar/vies:
    post:
      summary: Validate VAT in VIES
      tags:
      - Validation
      description: This endpoint allows validating that an intra-community VAT number is registered in the VIES census.
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
              - codigo_pais
              - iva
              properties:
                codigo_pais:
                  description: Country code to which the VAT number belongs.
                  type: string
                  example: DE
                iva:
                  description: Intra-community VAT number.
                  type: string
                  example: DE123456789
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/nifs/validar/vies' \
          --request POST \
          --header 'Authorization: Bearer <USER_API_KEY>' \
          --data-raw '{"codigo_pais": "DE", "iva": "DE123456789"}'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/nifs/validar/vies'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          data = {
            'codigo_pais': 'DE',
            'iva': 'DE123456789'
          }
          response = requests.post(url, headers=headers, json=data)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/nifs/validar/vies';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          const data = {
            'codigo_pais': 'DE',
            'iva': 'DE123456789'
          };
          fetch(url, { headers, method: 'POST', body: JSON.stringify(data) })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const data = {
            'codigo_pais': 'DE',
            'iva': 'DE123456789'
          };

          const response = await axios.post("https://api.verifacti.com/nifs/validar/vies", data, {
            headers: {
              "Authorization": "Bearer <API_KEY>",
              "Content-Type": "application/json"
            }
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/nifs/validar/vies";

          $headers = [
              "Authorization: Bearer <API_KEY>",
              "Content-Type: application/json"
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $body = <<<'JSON'
          {"codigo_pais": "DE", "iva": "DE123456789"}
          JSON;

          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"strings\"\n)\n\nfunc main() {\n\tbody := `\n{\"codigo_pais\": \"DE\", \"iva\": \"DE123456789\"}\n`\n\n\treq, err := http.NewRequest(\"POST\", \"https://api.verifacti.com/nifs/validar/vies\", strings.NewReader(body))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  String body = """
                          {"codigo_pais": "DE", "iva": "DE123456789"}
                          """;

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/nifs/validar/vies"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .header("Content-Type", "application/json")
                      .POST(HttpRequest.BodyPublishers.ofString(body))
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var body = @"
                      {""codigo_pais"": ""DE"", ""iva"": ""DE123456789""}
                  ";

                  var content = new StringContent(body, Encoding.UTF8, "application/json");

                  var response = await client.PostAsync("https://api.verifacti.com/nifs/validar/vies", content);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/nifs/validar/vies"

          oHttp.Open "POST", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"
          oHttp.setRequestHeader "Content-Type", "application/json"

          Dim sBody As String
          sBody = "{""codigo_pais"": ""DE"", ""iva"": ""DE123456789""}"

          oHttp.send sBody

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          description: VIES census response
          content:
            application/json:
              schema:
                type: object
                properties:
                  iva:
                    description: Intra-community VAT number being queried.
                    type: string
                    example: DE123456789
                  resultado:
                    type: string
                    example: IDENTIFICADO
                    description: |
                      Indicates whether the VAT number is identified or not. This API sometimes returns the ERROR API VIES result, which occurs when
                      the validation APIs of each country reach their request limit. This is a global limit and is not specific to the Verifacti IP or anything
                      of the sort.
                    enum:
                    - IDENTIFICADO
                    - NO IDENTIFICADO
                    - ERROR API VIES
        "400":
          description: Invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /representacion/generar/{nif}:
    post:
      summary: Generate Representation PDF
      tags:
      - Representation
      parameters:
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF corresponding to the invoice issuer
        example: B86561412
      description: |
        This endpoint allows downloading the representation grant PDF document for a VeriFactu NIF.
        <strong>The content of the downloaded document must not be modified. It should simply be signed.</strong>
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                tipo_entidad:
                  description: Entity type, individuals or legal entities.
                  enum:
                  - fisica
                  - juridica
                  example: juridica
                nombre:
                  type: string
                  description: Required for individuals. Full name of the invoice issuer.
                municipio:
                  type: string
                  description: Required for individuals. Municipality of residence of the invoice issuer.
                calle:
                  type: string
                  description: Required for individuals. Street of residence of the invoice issuer.
                numero:
                  type: string
                  description: Required for individuals. Street number of residence of the invoice issuer.
                nombre_entidad:
                  type: string
                  description: Required for legal entities. Entity name.
                municipio_entidad:
                  type: string
                  description: Required for legal entities. Municipality of the entity's registered office.
                calle_entidad:
                  type: string
                  description: Required for legal entities. Street of the entity's registered office.
                numero_entidad:
                  type: string
                  description: Required for legal entities. Street number of the entity's registered office.
                nombre_representante:
                  type: string
                  description: Required for legal entities. Full name of the entity's representative.
                nif_representante:
                  type: string
                  description: Required for legal entities. NIF of the entity's representative.
                municipio_representante:
                  type: string
                  description: Required for legal entities. Municipality of residence of the entity's representative.
                calle_representante:
                  type: string
                  description: Required for legal entities. Street of residence of the entity's representative.
                numero_representante:
                  type: string
                  description: Required for legal entities. Street number of residence of the entity's representative.
              example:
                tipo_entidad: juridica
                nombre_entidad: Mi empresa SL
                municipio_entidad: Madrid
                calle_entidad: Calle Mayor
                numero_entidad: "15"
                nombre_representante: Pablo García Gómez
                nif_representante: 16085921K
                municipio_representante: Madrid
                calle_representante: Gran Vía
                numero_representante: "43"
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/representacion/generar/B86561412' \
          --request POST \
          --header 'Content-Type: application/json' \
          --header 'Authorization: Bearer <USER_API_KEY>' \
          --data-raw '{"tipo_entidad": "juridica", "nombre_entidad": "Mi empresa SL", "municipio_entidad": "Madrid", "calle_entidad": "Calle Mayor", "numero_entidad": "15", "nombre_representante": "Pablo García Gómez", "nif_representante": "16085921K", "municipio_representante": "Madrid", "calle_representante": "Gran Vía", "numero_representante": "43"}' \
          --output modelo_representacion.pdf
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/representacion/generar/B86561412'
          headers = {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          data = {
            'tipo_entidad': 'juridica',
            'nombre_entidad': 'Mi empresa SL',
            'municipio_entidad': 'Madrid',
            'calle_entidad': 'Calle Mayor',
            'numero_entidad': '15',
            'nombre_representante': 'Pablo García Gómez',
            'nif_representante': '16085921K',
            'municipio_representante': 'Madrid',
            'calle_representante': 'Gran Vía',
            'numero_representante': '43'
          }
          response = requests.post(url, headers=headers, json=data)
          with open('modelo_representacion.pdf', 'wb') as f:
            f.write(response.content)
      - lang: JavaScript
        label: JavaScript
        source: |
          const { writeFile } = require('fs').promises;

          const url = 'https://api.verifacti.com/representacion/generar/B86561412';
          const headers = {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          const data = {
            'tipo_entidad': 'juridica',
            'nombre_entidad': 'Mi empresa SL',
            'municipio_entidad': 'Madrid',
            'calle_entidad': 'Calle Mayor',
            'numero_entidad': '15',
            'nombre_representante': 'Pablo García Gómez',
            'nif_representante': '16085921K',
            'municipio_representante': 'Madrid',
            'calle_representante': 'Gran Vía',
            'numero_representante': '43'
          };
          fetch(url, {
            method: 'POST',
            headers,
            body: JSON.stringify(data)
          })
            .then(response => response.blob())
            .then(blob => writeFile('modelo_representacion.pdf', blob))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");
          const fs = require("fs");

          const data = {
            "tipo_entidad": "juridica",
            "nombre_entidad": "Mi empresa SL",
            "municipio_entidad": "Madrid",
            "calle_entidad": "Calle Mayor",
            "numero_entidad": "15",
            "nombre_representante": "Pablo García Gómez",
            "nif_representante": "16085921K",
            "municipio_representante": "Madrid",
            "calle_representante": "Gran Vía",
            "numero_representante": "43"
          };

          const response = await axios.post("https://api.verifacti.com/representacion/generar/B86561412", data, {
            headers: {
              "Authorization": "Bearer <API_KEY>",
              "Content-Type": "application/json"
            },
            responseType: "arraybuffer"
          });

          fs.writeFileSync("modelo_representacion.pdf", response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/representacion/generar/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
              "Content-Type: application/json"
          ];

          $body = json_encode([
              "tipo_entidad" => "juridica",
              "nombre_entidad" => "Mi empresa SL",
              "municipio_entidad" => "Madrid",
              "calle_entidad" => "Calle Mayor",
              "numero_entidad" => "15",
              "nombre_representante" => "Pablo García Gómez",
              "nif_representante" => "16085921K",
              "municipio_representante" => "Madrid",
              "calle_representante" => "Gran Vía",
              "numero_representante" => "43"
          ]);

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          file_put_contents("modelo_representacion.pdf", $response);
          echo "HTTP Status: " . $httpCode . "\n";
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"os\"\n)\n\nfunc main() {\n\tdata := map[string]string{\n\t\t\"tipo_entidad\": \"juridica\",\n\t\t\"nombre_entidad\": \"Mi empresa SL\",\n\t\t\"municipio_entidad\": \"Madrid\",\n\t\t\"calle_entidad\": \"Calle Mayor\",\n\t\t\"numero_entidad\": \"15\",\n\t\t\"nombre_representante\": \"Pablo García Gómez\",\n\t\t\"nif_representante\": \"16085921K\",\n\t\t\"municipio_representante\": \"Madrid\",\n\t\t\"calle_representante\": \"Gran Vía\",\n\t\t\"numero_representante\": \"43\",\n\t}\n\tjsonBody, _ := json.Marshal(data)\n\n\treq, err := http.NewRequest(\"POST\", \"https://api.verifacti.com/representacion/generar/B86561412\", bytes.NewBuffer(jsonBody))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tos.WriteFile(\"modelo_representacion.pdf\", respBody, 0644)\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;
          import java.nio.file.Files;
          import java.nio.file.Path;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  String body = "{\"tipo_entidad\": \"juridica\", \"nombre_entidad\": \"Mi empresa SL\", \"municipio_entidad\": \"Madrid\", \"calle_entidad\": \"Calle Mayor\", \"numero_entidad\": \"15\", \"nombre_representante\": \"Pablo García Gómez\", \"nif_representante\": \"16085921K\", \"municipio_representante\": \"Madrid\", \"calle_representante\": \"Gran Vía\", \"numero_representante\": \"43\"}";

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/representacion/generar/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .header("Content-Type", "application/json")
                      .POST(HttpRequest.BodyPublishers.ofString(body))
                      .build();

                  HttpResponse<byte[]> response = client.send(request,
                      HttpResponse.BodyHandlers.ofByteArray());

                  Files.write(Path.of("modelo_representacion.pdf"), response.body());
                  System.out.println(response.statusCode());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.IO;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var body = @"{""tipo_entidad"": ""juridica"", ""nombre_entidad"": ""Mi empresa SL"", ""municipio_entidad"": ""Madrid"", ""calle_entidad"": ""Calle Mayor"", ""numero_entidad"": ""15"", ""nombre_representante"": ""Pablo García Gómez"", ""nif_representante"": ""16085921K"", ""municipio_representante"": ""Madrid"", ""calle_representante"": ""Gran Vía"", ""numero_representante"": ""43""}";

                  var content = new StringContent(body, Encoding.UTF8, "application/json");

                  var response = await client.PostAsync("https://api.verifacti.com/representacion/generar/B86561412", content);

                  var responseBytes = await response.Content.ReadAsByteArrayAsync();
                  File.WriteAllBytes("modelo_representacion.pdf", responseBytes);
                  Console.WriteLine($"Status: {response.StatusCode}");
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/representacion/generar/B86561412"

          oHttp.Open "POST", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"
          oHttp.setRequestHeader "Content-Type", "application/json"

          Dim sBody As String
          sBody = "{""tipo_entidad"": ""juridica"", ""nombre_entidad"": ""Mi empresa SL"", ""municipio_entidad"": ""Madrid"", ""calle_entidad"": ""Calle Mayor"", ""numero_entidad"": ""15"", ""nombre_representante"": ""Pablo García Gómez"", ""nif_representante"": ""16085921K"", ""municipio_representante"": ""Madrid"", ""calle_representante"": ""Gran Vía"", ""numero_representante"": ""43""}"

          oHttp.send sBody

          Debug.Print "Status: " & oHttp.Status

          Set oHttp = Nothing
      responses:
        "200":
          description: Representation grant PDF document
          headers:
            Content-Disposition:
              description: Content-Disposition header
              schema:
                type: string
                example: attachment; filename="modelo_representacion.pdf"
          content:
            application/pdf:
              schema:
                type: string
                format: binary
        "400":
          description: Invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /representacion/enviar/{nif}:
    post:
      summary: Submit Signed PDF
      tags:
      - Representation
      parameters:
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF corresponding to the invoice issuer
        example: B86561412
      description: |
        This endpoint submits the representation grant PDF document for a VeriFactu NIF.
        Once a representation document has been accepted, it cannot be resubmitted.
      requestBody:
        description: The PDF file to be processed
        required: true
        content:
          multipart/form-data:
            schema:
              type: string
              format: binary
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/representacion/enviar/B86561412' \
          --request POST \
          --header 'Authorization: Bearer <USER_API_KEY>' \
          --form 'file=@"/ruta/pdf.pdf"'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/representacion/enviar/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          with open('/ruta/pdf.pdf', 'rb') as pdf_file:
            files = {
                'file': ('pdf.pdf', pdf_file, 'application/pdf')
            }
            response = requests.post(url, headers=headers, files=files)
      - lang: JavaScript
        label: JavaScript
        source: |
          const fs = require('fs').promises;

          (async () => {
            try {
              const fileBuffer = await fs.readFile('/ruta/archivo.pdf');
              const pdfBlob = new Blob([fileBuffer], { type: 'application/pdf' });
              const form = new FormData();
              form.append('file', pdfBlob, 'archivo.pdf');

              return res = await fetch(
                'https://api.verifacti.com/representacion/enviar/B86561412',
                {
                  method: 'POST',
                  headers: {
                    'Authorization': 'Bearer <USER_API_KEY>'
                  },
                  body: form,
                }
              );

            } catch (err) {
              console.error('Upload error:', err);
            }
          })();
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");
          const FormData = require("form-data");
          const fs = require("fs");

          const form = new FormData();
          form.append("file", fs.createReadStream("/ruta/pdf.pdf"), {
            filename: "pdf.pdf",
            contentType: "application/pdf"
          });

          const response = await axios.post("https://api.verifacti.com/representacion/enviar/B86561412", form, {
            headers: {
              "Authorization": "Bearer <API_KEY>",
              ...form.getHeaders()
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/representacion/enviar/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_POSTFIELDS, [
              'file' => new CURLFile('/ruta/pdf.pdf', 'application/pdf', 'pdf.pdf')
          ]);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"io\"\n\t\"mime/multipart\"\n\t\"net/http\"\n\t\"os\"\n)\n\nfunc main() {\n\tvar buf bytes.Buffer\n\twriter := multipart.NewWriter(&buf)\n\tfile, err := os.Open(\"/ruta/pdf.pdf\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer file.Close()\n\tpart, err := writer.CreateFormFile(\"file\", \"pdf.pdf\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tio.Copy(part, file)\n\twriter.Close()\n\n\treq, err := http.NewRequest(\"POST\", \"https://api.verifacti.com/representacion/enviar/B86561412\", &buf)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\treq.Header.Set(\"Content-Type\", writer.FormDataContentType())\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.io.IOException;
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;
          import java.nio.file.Files;
          import java.nio.file.Path;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();
                  String boundary = "----FormBoundary" + System.currentTimeMillis();
                  Path filePath = Path.of("/ruta/pdf.pdf");
                  byte[] fileBytes = Files.readAllBytes(filePath);

                  String body = "--" + boundary + "\r\n"
                      + "Content-Disposition: form-data; name=\"file\"; filename=\"pdf.pdf\"\r\n"
                      + "Content-Type: application/pdf\r\n\r\n";
                  String end = "\r\n--" + boundary + "--\r\n";

                  byte[] bodyBytes = body.getBytes();
                  byte[] endBytes = end.getBytes();
                  byte[] requestBody = new byte[bodyBytes.length + fileBytes.length + endBytes.length];
                  System.arraycopy(bodyBytes, 0, requestBody, 0, bodyBytes.length);
                  System.arraycopy(fileBytes, 0, requestBody, bodyBytes.length, fileBytes.length);
                  System.arraycopy(endBytes, 0, requestBody, bodyBytes.length + fileBytes.length, endBytes.length);

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/representacion/enviar/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .header("Content-Type", "multipart/form-data; boundary=" + boundary)
                      .POST(HttpRequest.BodyPublishers.ofByteArray(requestBody))
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.IO;
          using System.Net.Http;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  using var form = new MultipartFormDataContent();
                  var fileContent = new ByteArrayContent(File.ReadAllBytes("/ruta/pdf.pdf"));
                  fileContent.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/pdf");
                  form.Add(fileContent, "file", "pdf.pdf");

                  var response = await client.PostAsync("https://api.verifacti.com/representacion/enviar/B86561412", form);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/representacion/enviar/B86561412"

          ' To upload files in VB6, it is recommended to use cURL from the command line
          ' or use an external library that supports multipart/form-data.
          ' Example using cURL from VB6:
          Shell "curl -X POST " & sUrl & " -H ""Authorization: Bearer <API_KEY>"" -F ""file=@C:\ruta\pdf.pdf"""

          Set oHttp = Nothing
      responses:
        "200":
          description: PDF submitted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  estado:
                    description: |
                      Representation status. The possible values are:
                      <ul style="list-style-type: disc">
                        <li>Correcto: The representation model has been received and validated correctly.</li>
                        <li>Rechazado: The representation model has been received but could not be validated.</li>
                        <li>Inexistente: The signed representation model has not been received.</li>
                      </ul>
                    enum:
                    - Correcto
                    - Rechazado
                    - Inexistente
                    type: string
                  error:
                    description: Error message when status=Rechazado
                    type: string
                example:
                  estado: Correcto
        "400":
          description: PDF not submitted correctly
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    description: Error message
                    type: string
                    example: Falta adjuntar fichero PDF
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          description: Internal server error or failure processing the PDF
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /representacion/cancelar/{nif}:
    put:
      summary: Cancel Signed PDF
      tags:
      - Representation
      parameters:
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF corresponding to the invoice issuer
        example: B86561412
      description: |
        This endpoint cancels the representation grant PDF document for a VeriFactu NIF.
        If the representation document is cancelled, invoices cannot be sent to the AEAT production environment for that NIF.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/representacion/cancelar/B86561412' \
          --request PUT \
          --header 'Content-Type: application/json' \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/representacion/cancelar/B86561412'
          headers = {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.put(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/representacion/cancelar/B86561412';
          const headers = {
            'Content-Type': 'application/json',
            'Authorization': 'Bearer <USER_API_KEY>'
          };

          return res = await fetch(url, {
            method: 'PUT',
            headers: headers,
          });
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.put("https://api.verifacti.com/representacion/cancelar/B86561412", null, {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/representacion/cancelar/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"PUT\", \"https://api.verifacti.com/representacion/cancelar/B86561412\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/representacion/cancelar/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .PUT(HttpRequest.BodyPublishers.noBody())
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.PutAsync("https://api.verifacti.com/representacion/cancelar/B86561412", null);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/representacion/cancelar/B86561412"

          oHttp.Open "PUT", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          description: PDF cancelled successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  estado:
                    description: Representation status
                    type: string
                example:
                  estado: Cancelado
        "404":
          description: Representation not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    description: Representation not found
                    type: string
                    example: Representation not found
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          description: Internal server error while processing the cancellation
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
  /representacion/descargar/{nif}:
    get:
      summary: Download Signed PDF
      tags:
      - Representation
      parameters:
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF corresponding to the invoice issuer NIF
        example: B86561412
      description: |
        This endpoint allows downloading the signed representation grant PDF document for a VeriFactu NIF.
        This endpoint is exclusive to VeriFactu NIFs.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/representacion/descargar/B86561412' \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/representacion/descargar/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.get(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/representacion/descargar/B86561412';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers, method: 'GET' })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.get("https://api.verifacti.com/representacion/descargar/B86561412", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/representacion/descargar/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"GET\", \"https://api.verifacti.com/representacion/descargar/B86561412\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/representacion/descargar/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .GET()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.GetAsync("https://api.verifacti.com/representacion/descargar/B86561412");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/representacion/descargar/B86561412"

          oHttp.Open "GET", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          description: PDF downloaded successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  url:
                    description: URL where the PDF is hosted. This URL expires after 15 minutes.
                    type: string
                    example: https://bucket.com/B86561412
        "404":
          description: PDF not found for the given NIF
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /representacion/estado/{nif}:
    get:
      summary: Representation Status
      tags:
      - Representation
      parameters:
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF corresponding to the invoice issuer
        example: B86561412
      description: This endpoint allows retrieving the representation status for a NIF.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/representacion/estado/B86561412' \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/representacion/estado/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.get(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/representacion/estado/B86561412';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers, method: 'GET' })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.get("https://api.verifacti.com/representacion/estado/B86561412", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/representacion/estado/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"GET\", \"https://api.verifacti.com/representacion/estado/B86561412\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/representacion/estado/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .GET()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.GetAsync("https://api.verifacti.com/representacion/estado/B86561412");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/representacion/estado/B86561412"

          oHttp.Open "GET", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          description: PDF submitted successfully
          content:
            application/json:
              schema:
                type: object
                properties:
                  estado:
                    description: |
                      Representation status. The possible values are:
                      <ul style="list-style-type: disc">
                        <li>Correcto: The representation model has been received and validated correctly.</li>
                        <li>Rechazado: The representation model has been received but could not be validated.</li>
                        <li>Inexistente: The signed representation model has not been received.</li>
                      </ul>
                    enum:
                    - Correcto
                    - Rechazado
                    - Inexistente
                    type: string
                  error:
                    description: Error message when status=Rechazado
                    type: string
                example:
                  estado: Correcto
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /webhooks:
    get:
      summary: List Webhooks
      tags:
      - Webhooks
      description: |
        This endpoint returns a list of all configured webhooks. By default, it returns both active and inactive webhooks in both environments,
        but allows filtering by active or inactive status and environment.
      parameters:
      - in: query
        name: entorno
        schema:
          type: string
          enum:
          - test
          - prod
        description: Parameter to filter webhooks by environment. If not included, all webhooks will be returned.
        example: test
      - in: query
        name: activos
        schema:
          type: boolean
        description: Parameter to filter webhooks by active or inactive status. If not included, all webhooks will be returned.
        example: true
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/webhooks?entorno=test&activos=true' \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/webhooks?entorno=test&activos=true'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.get(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/webhooks?entorno=test&activos=true';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.get("https://api.verifacti.com/webhooks?entorno=test&activos=true", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/webhooks?entorno=test&activos=true";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"GET\", \"https://api.verifacti.com/webhooks?entorno=test&activos=true\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/webhooks?entorno=test&activos=true"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .GET()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.GetAsync("https://api.verifacti.com/webhooks?entorno=test&activos=true");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/webhooks?entorno=test&activos=true"

          oHttp.Open "GET", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          description: Webhook list
          content:
            application/json:
              schema:
                type: array
                items:
                  properties:
                    id:
                      description: Webhook identifier.
                      type: string
                    url:
                      description: URL that will be called when the webhook fires.
                      type: string
                    entorno:
                      description: Webhook environment. Can be "test" or "prod".
                      type: string
                    activo:
                      description: Indicates whether the webhook is active or not.
                      type: boolean
                    nifs:
                      type: array
                      description: |
                        NIF list. When invoicing records are sent for any of these NIFs, the webhook is triggered with the tax authority's
                        result once obtained.
                      items:
                        type: string
                example:
                - id: 17067405-8c32-4efe-a7cb-8fad93403997
                  url: https://api.webdelcliente.com/webhook
                  entorno: test
                  activo: true
                  nifs:
                  - B12345678
                  - B87654321
                - id: 17067405-8c32-4efe-a7cb-8fad93403997
                  url: https://api.otraweb.com/webhook
                  entorno: test
                  activo: true
                  nifs:
                  - C12345678
        "400":
          description: Invalid query parameters
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
    post:
      summary: Add Webhook
      tags:
      - Webhooks
      description: This endpoint allows registering a webhook.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl --request POST 'https://api.verifacti.com/webhooks' \
          --header 'Authorization: Bearer <USER_API_KEY>' \
          --header 'Content-Type: application/json' \
          --data-raw '{
            "url": "https://api.webdelcliente.com/webhook",
            "entorno": "test",
            "secret": "mi-secreto",
            "nifs": [
              "B86561412",
              "B01345232"
            ]
          }'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/webhooks'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>',
            'Content-Type': 'application/json'
          }
          data = {
            'url': 'https://api.webdelcliente.com/webhook',
            'entorno': 'test',
            'secret': 'mi-secreto',
            'nifs': [
              'B86561412',
              'B01345232'
            ]}
          response = requests.post(url, headers=headers, json=data)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/webhooks';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>',
            'Content-Type': 'application/json'
          };
          const data = {
            'url': 'https://api.webdelcliente.com/webhook',
            'entorno': 'test',
            'secret': 'mi-secreto',
            'nifs': [
              'B86561412',
              'B01345232'
            ]
          }
          fetch(url, { headers, method: 'POST', body: JSON.stringify(data) })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const data = {
            "url": "https://api.webdelcliente.com/webhook",
            "entorno": "test",
            "secret": "mi-secreto",
            "nifs": [
              "B86561412",
              "B01345232"
            ]
          };

          const response = await axios.post("https://api.verifacti.com/webhooks", data, {
            headers: {
              "Authorization": "Bearer <API_KEY>",
              "Content-Type": "application/json"
            }
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/webhooks";

          $headers = [
              "Authorization: Bearer <API_KEY>",
              "Content-Type: application/json"
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $body = <<<'JSON'
          {
            "url": "https://api.webdelcliente.com/webhook",
            "entorno": "test",
            "secret": "mi-secreto",
            "nifs": [
              "B86561412",
              "B01345232"
            ]
          }
          JSON;

          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"strings\"\n)\n\nfunc main() {\n\tbody := `\n{\n  \"url\": \"https://api.webdelcliente.com/webhook\",\n  \"entorno\": \"test\",\n  \"secret\": \"mi-secreto\",\n  \"nifs\": [\n    \"B86561412\",\n    \"B01345232\"\n  ]\n}\n`\n\n\treq, err := http.NewRequest(\"POST\", \"https://api.verifacti.com/webhooks\", strings.NewReader(body))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  String body = """
                          {
                            "url": "https://api.webdelcliente.com/webhook",
                            "entorno": "test",
                            "secret": "mi-secreto",
                            "nifs": [
                              "B86561412",
                              "B01345232"
                            ]
                          }
                          """;

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/webhooks"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .header("Content-Type", "application/json")
                      .POST(HttpRequest.BodyPublishers.ofString(body))
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var body = @"
                      {
            ""url"": ""https://api.webdelcliente.com/webhook"",
            ""entorno"": ""test"",
            ""secret"": ""mi-secreto"",
            ""nifs"": [
              ""B86561412"",
              ""B01345232""
            ]
          }
                  ";

                  var content = new StringContent(body, Encoding.UTF8, "application/json");

                  var response = await client.PostAsync("https://api.verifacti.com/webhooks", content);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/webhooks"

          oHttp.Open "POST", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"
          oHttp.setRequestHeader "Content-Type", "application/json"

          Dim sBody As String
          sBody = "{" & vbCrLf & _
                 "  ""url"": ""https://api.webdelcliente.com/webhook""," & vbCrLf & _
                 "  ""entorno"": ""test""," & vbCrLf & _
                 "  ""secret"": ""mi-secreto""," & vbCrLf & _
                 "  ""nifs"": [" & vbCrLf & _
                 "    ""B86561412""," & vbCrLf & _
                 "    ""B01345232""" & vbCrLf & _
                 "  ]" & vbCrLf & _
                 "}"

          oHttp.send sBody

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      requestBody:
        content:
          application/json:
            schema:
              type: object
              required:
              - url
              - entorno
              properties:
                url:
                  description: URL that will be called when the webhook fires.
                  type: string
                entorno:
                  description: Webhook environment. Can be "test" or "prod".
                  type: string
                  enum:
                  - test
                  - prod
                secret:
                  description: |
                    Optional parameter. A secret key shared between our API and the webhook receiver. It is used to generate the
                    HMAC signature that accompanies each notification. When receiving a webhook, the receiver can use this key to recalculate the message
                    signature and compare it with the signature provided in the `X-Webhook-Signature` header. If both signatures match, it confirms that the
                    message is authentic and has not been modified.
                nifs:
                  description: |
                    NIF list. When invoicing records are sent for any of these NIFs, the webhook will be triggered with the tax authority's
                    result once obtained. These NIFs must be registered in the environment in which the webhook is being created.
              example:
                url: https://api.webdelcliente.com/webhook
                entorno: test
                secret: mi-secreto
                nifs:
                - B86561412
                - B01345232
      responses:
        "200":
          $ref: "#/components/responses/webhookResponse"
        "400":
          description: Invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "409":
          description: Webhook already exists with that URL
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /webhooks/{webhook_id}:
    get:
      summary: Webhook Information
      tags:
      - Webhooks
      parameters:
      - in: path
        name: webhook_id
        schema:
          type: string
        required: true
        description: Webhook identifier
        example: 17067405-8c32-4efe-a7cb-8fad93403997
      description: This endpoint returns the information of a specific webhook.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997' \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.get(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.get("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"GET\", \"https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .GET()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.GetAsync("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997"

          oHttp.Open "GET", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          $ref: "#/components/responses/webhookResponse"
        "404":
          description: Webhook not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
    put:
      summary: Modify Webhook
      tags:
      - Webhooks
      parameters:
      - in: path
        name: webhook_id
        schema:
          type: string
        required: true
        description: Webhook identifier
        example: 17067405-8c32-4efe-a7cb-8fad93403997
      description: This endpoint allows modifying a specific webhook.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl --request PUT 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997' \
          --header 'Authorization: Bearer <USER_API_KEY>' \
          --header 'Content-Type: application/json' \
          --data-raw '{
            "url": "https://api.webdelcliente.com/webhook",
            "secret": "mi-secreto",
            "nifs": [
              "B86561412",
              "B01345232"
            ]
          }'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>',
            'Content-Type': 'application/json'
          }
          data = {
            'url': 'https://api.webdelcliente.com/webhook',
            'secret': 'mi-secreto',
            'nifs': [
              'B86561412',
              'B01345232'
            ]
          }
          response = requests.put(url, headers=headers, json=data)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>',
            'Content-Type': 'application/json'
          };
          const data = {
            'url': 'https://api.webdelcliente.com/webhook',
            'secret': 'mi-secreto',
            'nifs': [
              'B86561412',
              'B01345232'
            ]
          };
          fetch(url, { headers, method: 'PUT', body: JSON.stringify(data) })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const data = {
            'url': 'https://api.webdelcliente.com/webhook',
            'secret': 'mi-secreto',
            'nifs': [
              'B86561412',
              'B01345232'
            ]
          };

          const response = await axios.put("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997", data, {
            headers: {
              "Authorization": "Bearer <API_KEY>",
              "Content-Type": "application/json"
            }
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997";

          $headers = [
              "Authorization: Bearer <API_KEY>",
              "Content-Type: application/json"
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

          $body = <<<'JSON'
          {
            "url": "https://api.webdelcliente.com/webhook",
            "secret": "mi-secreto",
            "nifs": [
              "B86561412",
              "B01345232"
            ]
          }
          JSON;

          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
          curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"strings\"\n)\n\nfunc main() {\n\tbody := `\n{\n  \"url\": \"https://api.webdelcliente.com/webhook\",\n  \"secret\": \"mi-secreto\",\n  \"nifs\": [\n    \"B86561412\",\n    \"B01345232\"\n  ]\n}\n`\n\n\treq, err := http.NewRequest(\"PUT\", \"https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997\", strings.NewReader(body))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  String body = """
                          {
                            "url": "https://api.webdelcliente.com/webhook",
                            "secret": "mi-secreto",
                            "nifs": [
                              "B86561412",
                              "B01345232"
                            ]
                          }
                          """;

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .header("Content-Type", "application/json")
                      .PUT(HttpRequest.BodyPublishers.ofString(body))
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var body = @"
                      {
            ""url"": ""https://api.webdelcliente.com/webhook"",
            ""secret"": ""mi-secreto"",
            ""nifs"": [
              ""B86561412"",
              ""B01345232""
            ]
          }
                  ";

                  var content = new StringContent(body, Encoding.UTF8, "application/json");

                  var response = await client.PutAsync("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997", content);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997"

          oHttp.Open "PUT", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"
          oHttp.setRequestHeader "Content-Type", "application/json"

          Dim sBody As String
          sBody = "{" & vbCrLf & _
                 "  ""url"": ""https://api.webdelcliente.com/webhook""," & vbCrLf & _
                 "  ""secret"": ""mi-secreto""," & vbCrLf & _
                 "  ""nifs"": [" & vbCrLf & _
                 "    ""B86561412""," & vbCrLf & _
                 "    ""B01345232""" & vbCrLf & _
                 "  ]" & vbCrLf & _
                 "}"

          oHttp.send sBody

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      requestBody:
        content:
          application/json:
            schema:
              type: object
              properties:
                url:
                  type: string
                  description: URL that will be called when the webhook fires.
                  example: https://api.webdelcliente.com/webhook
                secret:
                  type: string
                  description: Key to generate the HMAC signature.
                  example: mi-secreto
                activo:
                  type: boolean
                  description: Indicates whether the webhook will be active or not.
                  example: true
                nifs:
                  type: array
                  description: |
                    NIF list. When invoicing records are sent for any of these NIFs, the webhook will be triggered with the tax authority's
                    result once obtained. These NIFs must be registered in the webhook's environment.
                  items:
                    type: string
                    example:
                    - B86561412
                    - B01345232
      responses:
        "200":
          $ref: "#/components/responses/webhookResponse"
        "400":
          description: Invalid input data
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "404":
          description: Webhook not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "409":
          description: Webhook URL conflicts with an existing one
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
    delete:
      summary: Delete Webhook
      tags:
      - Webhooks
      parameters:
      - in: path
        name: webhook_id
        schema:
          type: string
        required: true
        description: Webhook identifier
        example: 17067405-8c32-4efe-a7cb-8fad93403997
      description: This endpoint allows deleting a specific webhook.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997' \
          --request DELETE \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.delete(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers, method: 'DELETE' })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.delete("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"DELETE\", \"https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .DELETE()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.DeleteAsync("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997"

          oHttp.Open "DELETE", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          $ref: "#/components/responses/okResponse"
        "404":
          description: Webhook not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
  /webhooks/{webhook_id}/nifs/{nif}:
    post:
      summary: Associate NIF with Webhook
      tags:
      - Webhooks
      parameters:
      - in: path
        name: webhook_id
        schema:
          type: string
        required: true
        description: Webhook identifier
        example: 17067405-8c32-4efe-a7cb-8fad93403997
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF
        example: B86561412
      description: This endpoint allows associating a specific NIF with a specific webhook.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412' \
          --request POST \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.post(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers, method: 'POST' })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.post("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412", null, {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_POST, true);

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"POST\", \"https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .POST(HttpRequest.BodyPublishers.noBody())
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.PostAsync("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412", null);

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412"

          oHttp.Open "POST", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          $ref: "#/components/responses/okResponse"
        "404":
          description: Webhook or NIF not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
    delete:
      summary: Dissociate NIF from Webhook
      tags:
      - Webhooks
      parameters:
      - in: path
        name: webhook_id
        schema:
          type: string
        required: true
        description: Webhook identifier
        example: 17067405-8c32-4efe-a7cb-8fad93403997
      - in: path
        name: nif
        schema:
          type: string
        required: true
        description: NIF
        example: B86561412
      description: This endpoint allows dissociating a specific NIF from a specific webhook.
      x-codeSamples:
      - lang: cURL
        label: cURL
        source: |
          curl 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412' \
          --request DELETE \
          --header 'Authorization: Bearer <USER_API_KEY>'
      - lang: Python
        label: Python
        source: |
          import requests
          url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412'
          headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          }
          response = requests.delete(url, headers=headers)
      - lang: JavaScript
        label: JavaScript
        source: |
          const url = 'https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412';
          const headers = {
            'Authorization': 'Bearer <USER_API_KEY>'
          };
          fetch(url, { headers, method: 'DELETE' })
            .then(response => response.json())
            .then(data => console.log(data))
            .catch(error => console.error(error));
          }
      - lang: Node.js
        label: Node.js
        source: |-
          const axios = require("axios");

          const response = await axios.delete("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412", {
            headers: {
              "Authorization": "Bearer <API_KEY>"
            },
          });

          console.log(response.data);
      - lang: PHP
        label: PHP
        source: |-
          <?php

          $url = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412";

          $headers = [
              "Authorization: Bearer <API_KEY>",
          ];

          $ch = curl_init($url);
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
          curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");

          $response = curl_exec($ch);
          $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
          curl_close($ch);

          echo "HTTP Status: " . $httpCode . "\n";
          echo $response;
      - lang: Go
        label: Go
        source: "package main\n\nimport (\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n)\n\nfunc main() {\n\treq, err := http.NewRequest(\"DELETE\", \"https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412\", nil)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\treq.Header.Set(\"Authorization\", \"Bearer <API_KEY>\")\n\n\tclient := &http.Client{}\n\tresp, err := client.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer resp.Body.Close()\n\n\trespBody, _ := io.ReadAll(resp.Body)\n\tfmt.Println(\"Status:\", resp.StatusCode)\n\tfmt.Println(string(respBody))\n}"
      - lang: Java
        label: Java
        source: |-
          import java.net.URI;
          import java.net.http.HttpClient;
          import java.net.http.HttpRequest;
          import java.net.http.HttpResponse;

          public class Main {
              public static void main(String[] args) throws Exception {
                  HttpClient client = HttpClient.newHttpClient();

                  HttpRequest request = HttpRequest.newBuilder()
                      .uri(URI.create("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412"))
                      .header("Authorization", "Bearer <API_KEY>")
                      .DELETE()
                      .build();

                  HttpResponse<String> response = client.send(request,
                      HttpResponse.BodyHandlers.ofString());

                  System.out.println(response.statusCode());
                  System.out.println(response.body());
              }
          }
      - lang: C#
        label: C#
        source: |-
          using System;
          using System.Net.Http;
          using System.Text;
          using System.Threading.Tasks;

          class Program
          {
              static async Task Main()
              {
                  using var client = new HttpClient();
                  client.DefaultRequestHeaders.Add("Authorization", "Bearer <API_KEY>");

                  var response = await client.DeleteAsync("https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412");

                  var responseBody = await response.Content.ReadAsStringAsync();
                  Console.WriteLine($"Status: {response.StatusCode}");
                  Console.WriteLine(responseBody);
              }
          }
      - lang: VB6
        label: VB6
        source: |-
          Dim oHttp As Object
          Dim sUrl As String
          Dim sResponse As String

          Set oHttp = CreateObject("MSXML2.XMLHTTP.6.0")

          sUrl = "https://api.verifacti.com/webhooks/17067405-8c32-4efe-a7cb-8fad93403997/nifs/B86561412"

          oHttp.Open "DELETE", sUrl, False
          oHttp.setRequestHeader "Authorization", "Bearer <API_KEY>"

          oHttp.send

          sResponse = oHttp.responseText
          Debug.Print "Status: " & oHttp.Status
          Debug.Print sResponse

          Set oHttp = Nothing
      responses:
        "200":
          $ref: "#/components/responses/okResponse"
        "204":
          description: NIF successfully dissociated from the webhook (no content)
        "404":
          description: Webhook or NIF not found
          content:
            application/json:
              schema:
                type: object
                properties:
                  error:
                    type: string
        "401":
          $ref: "#/components/responses/unauthorizedResponse"
        "500":
          $ref: "#/components/responses/serverErrorResponse"
components:
  schemas:
    WebhookNotification:
      type: array
      description: |
        Body sent to the webhook URL. It is an array with one element per invoicing record included in the
        submission that triggered the notification.
      items:
        $ref: "#/components/schemas/WebhookNotificationItem"
      example:
        - uuid: b018ced3-b362-4494-8776-9eefff1c160c
          nif: A15022510
          serie: A
          numero: "34547"
          fecha_expedicion: 13-02-2026
          operacion: Alta
          url: https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?nif=A15022510&numserie=A34547&fecha=13-02-2026&importe=242
          estado: Correcto
        - uuid: f4504c29-78ca-4491-9a10-b6b727a20c36
          nif: A15022510
          serie: A
          numero: "34548"
          fecha_expedicion: 13-02-2026
          operacion: Alta
          url: https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?nif=A15022510&numserie=A34548&fecha=13-02-2026&importe=751
          estado: Aceptado con errores
          codigo_error: "2005"
          mensaje_error: El campo ImporteTotal tiene un valor incorrecto para el valor de los campos BaseImponibleOimporteNoSujeto, CuotaRepercutida y CuotaRecargoEquivalencia suministrados.
    WebhookNotificationItem:
      type: object
      description: |
        Result for a single invoicing record. The shape matches the response returned by the `Record Status`
        endpoint of the VeriFactu or TicketBai APIs.
      properties:
        uuid:
          type: string
          format: uuid
          description: Identifier of the invoicing record in our platform.
          example: b018ced3-b362-4494-8776-9eefff1c160c
        nif:
          type: string
          description: NIF of the issuer the record belongs to.
          example: A15022510
        serie:
          type: string
          description: Invoice series.
          example: A
        numero:
          type: string
          description: Invoice number.
          example: "34547"
        fecha_expedicion:
          type: string
          description: Invoice issue date in `DD-MM-YYYY` format.
          example: 13-02-2026
        operacion:
          type: string
          description: |
            Type of operation performed on the record. For VeriFactu notifications the possible values are:
            <ul style="list-style: disc; margin-top: 6px; margin-bottom: 0px;">
              <li>Alta</li>
              <li>Subsanacion</li>
              <li>Anulación</li>
              <li>Alta (rechazo previo)</li>
              <li>Alta (rechazo previo de subsanacion)</li>
              <li>Anulación (rechazo previo)</li>
              <li>Anulación (sin registro)</li>
              <li>Anulación (rechazo previo sin registro)</li>
            </ul>

            For TicketBai notifications the possible values are:
            <ul style="list-style: disc; margin-top: 6px; margin-bottom: 0px;">
              <li>Alta</li>
              <li>Subsanacion</li>
              <li>Modificacion</li>
              <li>Anulación</li>
              <li>Anulación (rechazo previo)</li>
            </ul>
          example: Alta
        estado:
          type: string
          description: |
            Status of the invoicing record. Values match those of the `Record Status` endpoint:
            <ul style="list-style: disc; margin-top: 6px; margin-bottom: 0px;">
              <li>Pendiente: Record queued, not yet processed.</li>
              <li>Correcto: Record processed successfully by the tax authority.</li>
              <li>Aceptado con errores: Accepted with errors; a correction or rectification record is required.</li>
              <li>Incorrecto: Rejected by the tax authority; a correction or rectification is required.</li>
              <li>Duplicado: Not accepted because a record with the same (serie, numero, fecha_expedicion) already exists.</li>
              <li>Anulado: Cancellation record processed successfully.</li>
              <li>Factura inexistente: Cancellation not accepted because the invoice does not exist.</li>
              <li>No registrado: Rejected by the tax authority.</li>
              <li>Error servidor AEAT: Transient error on the tax authority side; the record will be retried automatically.</li>
            </ul>
          example: Correcto
        url:
          type: string
          description: QR code verification URL.
          example: https://prewww2.aeat.es/wlpl/TIKE-CONT/ValidarQR?nif=A15022510&numserie=A34547&fecha=13-02-2026&importe=242
        codigo_error:
          type: string
          description: |
            Error code as returned by the tax authority. Only present on VeriFactu notifications and when
            `estado` indicates an error (`Aceptado con errores`, `Incorrecto`, `No registrado`, etc.).
          example: "2005"
        mensaje_error:
          type: string
          description: |
            Error description as returned by the tax authority. Present when `estado` indicates an error.
          example: El campo ImporteTotal tiene un valor incorrecto para el valor de los campos suministrados.
        estado_registro_duplicado:
          type: string
          description: |
            Status of the previously existing record. Only present on VeriFactu notifications when
            `estado` is `Duplicado`.
        tbai:
          type: string
          description: |
            TicketBai record fingerprint (hash). Only present on TicketBai notifications.
  responses:
    unauthorizedResponse:
      description: Unauthorized — invalid or missing API key.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
    serverErrorResponse:
      description: Internal server error.
      content:
        application/json:
          schema:
            type: object
            properties:
              error:
                type: string
    okResponse:
      description: OK
      content:
        application/json:
          schema:
            type: object
            properties:
              message:
                description: Message.
                type: string
                example: OK
    nifResponse:
      description: NIF
      content:
        application/json:
          schema:
            type: object
            properties:
              nif:
                description: NIF.
                type: string
                example: B86561412
              entorno:
                description: NIF environment.
                type: string
                example: test
              hacienda:
                description: |
                  Tax authority the NIF is linked to. The possible values are:
                  <ol style="list-style-type: disc">
                    <li>verifactu</li>
                    <li>alava</li>
                    <li>guipuzcoa</li>
                    <li>vizcaya</li>
                  </ol>
                type: string
                example: verifactu
              webhooks:
                description: List of webhook identifiers associated with the NIF.
                type: array
                items:
                  type: string
                  example: 17067405-8c32-4efe-a7cb-8fad93403997
              nombre:
                description: Full name or company name of the NIF.
                type: string
                example: Mi empresa SL
              activo:
                description: Indicates whether the NIF is active or not.
                type: boolean
                example: true
              direccion:
                description: NIF address.
                type: string
                example: Calle Mayor 15
              cp:
                description: NIF postal code.
                type: string
                example: "28040"
              poblacion:
                description: NIF city.
                type: string
                example: Madrid
              provincia:
                description: NIF province.
                type: string
                example: Madrid
              fecha_creacion:
                description: NIF creation date.
                type: string
                example: 2024-12-01T12:18:21.671000Z
              fecha_modificacion:
                description: Date of the last NIF modification.
                type: string
                example: 2024-12-07T16:16:51.671000Z
              pagado_hasta:
                type: string
                example: 2025-06-04T00:00:00Z
                description: |
                  Field only available for production NIFs, as these are the only ones that require payment.
                  This field indicates the date until which the NIF has been paid for. If the NIF is active on that date,
                  it will be renewed automatically and the date will be updated automatically.
              representacion:
                enum:
                - Correcto
                - Rechazado
                - Inexistente
                example: Correcto
                description: |
                  Indicates the status of the NIF's representation model. The possible values are:
                  <ul style="list-style-type: disc">
                    <li>Correcto: The representation model has been received and validated correctly.</li>
                    <li>Rechazado: The representation model has been received but could not be validated.</li>
                    <li>Inexistente: The signed representation model has not been received.</li>
                  </ul>

                  This field is only present for VeriFactu NIFs. For production NIFs, the representation status must be
                  "Correcto" in order to send invoices.
                type: string
              pdf:
                type: string
                example: https://bucket.com/4f4a6b5b-8c32-4efe-a7cb-8fad93403997.pdf
                description: |
                  URL where the representation model for this NIF is hosted if it has been submitted. This URL is valid
                  for 15 minutes from the time of the request. This field is only present for VeriFactu NIFs.
              label:
                type: string
                example: Customer A
                description: Label associated with the NIF. May be `null` if none has been assigned.
    webhookResponse:
      description: Webhook
      content:
        application/json:
          schema:
            type: object
            properties:
              id:
                description: Webhook identifier.
                type: string
              url:
                description: URL that will be called when the webhook fires.
                type: string
              entorno:
                description: Webhook environment. Can be "test" or "prod".
                type: string
              secret:
                description: Key to generate the HMAC signature.
                type: string
              activo:
                description: Indicates whether the webhook is active or not.
                type: boolean
              nifs:
                type: array
                description: |
                  NIF list. When invoicing records are sent for any of these NIFs, the webhook is triggered with the tax authority's
                  result once obtained.
                items:
                  type: string
            example:
              id: 17067405-8c32-4efe-a7cb-8fad93403997
              url: https://api.webdelcliente.com/webhook
              entorno: test
              secret: mi-secreto
              activo: true
              nifs:
              - B86561412
              - B01345232
