Saltar a contenido

Patch a CFDI template

Patch a scoped template of the issuer: an RFC 6902 JSON Patch applied to a copy of its cfdi, and its name and note when given. patch is an array of at most 100 operations (add, remove, replace, move, copy, test), applied in order. Paths are JSON Pointers from the CFDI root, for example /Conceptos/0/Cantidad. At least one of patch, name and note is required. The save checks run on the result: TipoDeComprobante must stay I, E or P, a blank note is refused, and the cfdi may not contain Version, Emisor, LugarExpedicion or Fecha. 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. Nothing is written on any failure. A global template is invalid_state, since global templates are read-only. Drafts made from the template are not changed. The result is the template.

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

Parámetros

Parámetro Tipo Obligatorio Descripción
template_id string Sí Id of the template, from list_cfdi_template.
patch array de object No RFC 6902 operations, applied in order. add, replace and test take a value; move and copy take a from.
name string No New name of the template.
note string No New note of the template.
issuer string Sí Id of the issuer the call acts for, from list_issuers.

Esquema de entrada (JSON Schema)

{
  "type": "object",
  "properties": {
    "template_id": {
      "type": "string",
      "description": "Id of the template, from list_cfdi_template."
    },
    "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"
        ]
      }
    },
    "name": {
      "type": "string",
      "description": "New name of the template."
    },
    "note": {
      "type": "string",
      "description": "New note of the template."
    },
    "issuer": {
      "type": "string",
      "format": "uuid",
      "description": "Id of the issuer the call acts for, from list_issuers."
    }
  },
  "required": [
    "template_id",
    "issuer"
  ]
}