Saltar a contenido

Patch a draft's CFDI document

Apply an RFC 6902 JSON Patch to a draft's CFDI document. patch is an array of at most 100 operations (add, remove, replace, move, copy, test), applied in order to a copy of the stored CFDI. Paths are JSON Pointers from the CFDI root, for example /Conceptos/0/Cantidad. expected_version is the draft's revision counter (the version field of get_cfdi, which starts at 1 and goes up on every change), not the CFDI Version attribute (4.0). A stale expected_version answers a conflict with the current version. A patch that does not apply (a missing path, an unknown operation, a failed test, or more than 100 operations) answers invalid_argument with op_index, path and reason, and nothing is written. Drafts only: a signed or canceled CFDI answers invalid_state, and so does a draft with an open receiver request (revoke_receiver_request closes it). Returns the stored CFDI in the get_cfdi shape with the new version.

Alcance (scope): invoices:write · Características: Destructiva, Idempotente

Parámetros

Parámetro Tipo Obligatorio Descripción
invoice_id string Sí
expected_version integer Sí The draft's version from get_cfdi (starts at 1), not the CFDI Version attribute.
patch array de object Sí RFC 6902 operations, applied in order. add, replace and test take a value; move and copy take a from.
issuer string Sí Id of the issuer the call acts for, from list_issuers.

Esquema de entrada (JSON Schema)

{
  "type": "object",
  "properties": {
    "invoice_id": {
      "type": "string"
    },
    "expected_version": {
      "type": "integer",
      "minimum": 1,
      "description": "The draft's version from get_cfdi (starts at 1), not the CFDI Version attribute."
    },
    "patch": {
      "type": "array",
      "maxItems": 100,
      "description": "RFC 6902 operations, applied in order. add, replace and test take a value; move and copy take a from.",
      "items": {
        "type": "object",
        "properties": {
          "op": {
            "type": "string",
            "enum": [
              "add",
              "remove",
              "replace",
              "move",
              "copy",
              "test"
            ]
          },
          "path": {
            "type": "string",
            "description": "A JSON Pointer from the CFDI root."
          },
          "from": {
            "type": "string",
            "description": "The source JSON Pointer of move and copy."
          },
          "value": {
            "description": "The value of add, replace and test."
          }
        },
        "required": [
          "op",
          "path"
        ]
      }
    },
    "issuer": {
      "type": "string",
      "format": "uuid",
      "description": "Id of the issuer the call acts for, from list_issuers."
    }
  },
  "required": [
    "invoice_id",
    "expected_version",
    "patch",
    "issuer"
  ]
}