ES | EN

📄 MIPYME Documents

Update a specific document

PUT
Endpoint URL https://api-billing.koywe.com/V1/documents/{document_id}
Requires authentication

Authentication

Send header Authorization: Bearer <token> (obtained from POST /auth) for protected endpoints.

Parameters

NameLocationTypeRequiredDescription
document_idpathstring

Request body — fields

FieldTypeRequiredDescription
document_idintegerOptionalDocument ID.
document_statusintegerOptionalIndicates the status of the document. 0 = Draft (Chile only), 1 = issued, 2 = cancelled (Mexico only). Changing this value through PATCH operations will issue or cancel the document.
headerobjectOptional
header.account_idintegerOptionalAccount ID.
header.document_type_idintegerAlways requiredDocument type ID according to document type table.
header.document_type_taxbureaustringOptionalType of document at the tax bureau.
header.document_numberintegerOptionalDocument number.
header.received_issued_flagintegerOptional0 = received
1 = issued
header.taxbureau_validation_statusintegerOptionalDocument status at the tax bureau.
header.issue_datestring (date)Always requiredDocument issue date.
header.issuer_tax_id_codestringOptionalTax ID code according to tax id table. Required when the document requires the receiver to be specified.
header.issuer_tax_id_typestringOptionalTax ID type according to tax id table. Required when the document requires the receiver to be specified.
header.issuer_legal_namestringOptionalIssuer legal name
header.issuer_addressstringAlways requiredIssuer address
header.issuer_districtstringAlways requiredIdentifier for the district of the document issuer
header.issuer_citystringAlways requiredIdentifier for the city of the document issuer
header.issuer_state_idintegerOptionalRefers to the issuer's state. Empty if it doesn't apply. This is a required field on some countries, check the examples for your country
header.issuer_country_idintegerOptionalIdentifier for the country of the document issuer
header.issuer_phonestringAlways requiredIssuer phone number
header.issuer_activitystringAlways requiredRepresents the activity or business operation of the document issuer
header.customer_supplier_idintegerOptionalReturns the customer or supplier ID
header.receiver_tax_id_codestringOptionalThe tax identification code of the document receiver
header.receiver_tax_id_typestringOptionalTax ID type according to tax id table. Required when the document requires the receiver to be specified.
header.receiver_legal_namestringOptionalReceiver legal name
header.receiver_addressstringAlways requiredRequired address
header.receiver_districtstringAlways requiredThe location code of the document receiver
header.receiver_citystringAlways requiredThe city of the document receiver
header.receiver_state_idintegerOptionalRefers to the recipient's state. Empty if it doesn't apply. This is a required field on some countries, check the examples for your country
header.receiver_country_idintegerOptionalCountry ID according to ID table
header.receiver_phonestringAlways requiredThe phone of the document receiver
header.receiver_activitystringAlways requiredThe activity of the document receiver
header.receiver_postalcodestringOptionalOptional postal code according to the national format.
header.payment_conditionsstringOptionalPayment due dates separated by comma. Example:
0 = same day
30 = 30 days
0,30 = 50% on issuance date, 50% 30 days later
0,30,60 = 33% on issuance, 33% 30 days, 34% 60 days
header.currency_idnumberAlways requiredCurrency ID according to currency table
header.exchange_rate_valueintegerOptionalOnly when currency_id is defined and its value is a foreign currency.
header.sale_modalityintegerOptionalOnly for export documents: optional.
Valid values:
1 = Sale agreed
2 = Under condition
3 = Free consignment
4 = Consignment with minimum sale
9 = No payment
header.sale_clauseintegerOptionalOnly for export documents: optional.
Valid values:
1 = CIF
2 = CFR
3 = EXW
4 = FAS
5 = FOB
6 = S/CL
9 = DDP
10 = FCA
11 = CPT
12 = CIP
17 = DAT
18 = DAP
8 = Other
header.transportation_doc_typenumberOptionalWaybills only.
1 = Operation constitutes a sale
2 = Ventas por efectuar
3 = Consignaciones
4 = Entrega gratuita
5 = Traslados internos
6 = Otros traslados no venta
7 = Guía de devolución
8 = Traslado para exportación (no venta)
9 = Venta para exportación
header.transportation_doc_billingnumberOptionalWaybills only.
1 = Despacho por cuenta del receptor
2 = Despacho por cuenta del emisor a instalaciones del receptor
3 = Despacho por cuenta del emisor a otras instalaciones
header.document_statusnumberOptional0 = draft
1 = document_issued
2 = document sent to counterparty
3 = document accepted by counterparty
detailsarray<object>Optional
details[].quantitynumberAlways requiredQuantity of this product or service included in this line
details[].line_descriptionstringOptionalShort description to be included in the invoice as line title. Max 100 chars
details[].unit_measurestringOptionalUnit that this line is measured in
details[].unit_pricenumberAlways requiredPrice per unit
details[].long_descriptionstringOptionalLong description to be included in the invoice as line title. Max 100 chars
details[].modifier_amountnumberOptional
details[].total_taxesnumberOptionalTotal of all taxes included for this detail
details[].modifier_percentagenumberOptionalPositive or negative percentage to be applied before calculating the line total. Example: -6.5 for a 6.5% discount
details[].total_amount_linenumberAlways requiredTotal of the line, including net price and taxes
totalsobjectOptional
totals.net_amountnumberAlways requiredTotal of all net values from each of the detail lines.
totals.taxes_amountnumberOptionalTotal of all other taxes
totals.total_amountnumberAlways requiredDocument grand total
electronic_documentobjectOptional
electronic_document.document_xmlstringOptionalBase64 encoded XML
electronic_document.document_pdfstringOptionalBase64 encoded PDF
electronic_document.stamp_imgstringOptionalBase64 encoded stamp image
electronic_document.document_transfer_copy_pdfstringOptionalBase64 encoded transfer copy PDF (copia cedible). Present when pdf_transfer_copy option was used on create or GET. VALID ONLY FOR CHILE.
payment_linkobjectOptional
payment_link.payment_urlstringOptionalURL of the payment link for the document
resultobjectOptional
result.statusintegerOptionalRepresents the current status of the result
result.error_messagestringOptionalURL of the payment link for the document

Request body — JSON example

{
    "document_id": 0,
    "document_status": 0,
    "header": {
        "account_id": 0,
        "document_type_id": 0,
        "document_type_taxbureau": "string",
        "document_number": 0,
        "received_issued_flag": 0,
        "taxbureau_validation_status": 0,
        "issue_date": "string",
        "issuer_tax_id_code": "string",
        "issuer_tax_id_type": "string",
        "issuer_legal_name": "string",
        "issuer_address": "string",
        "issuer_district": "string",
        "issuer_city": "string",
        "issuer_state_id": 0,
        "issuer_country_id": 0,
        "issuer_phone": "string",
        "issuer_activity": "string",
        "customer_supplier_id": 0,
        "receiver_tax_id_code": "string",
        "receiver_tax_id_type": "string",
        "receiver_legal_name": "string",
        "receiver_address": "string",
        "receiver_district": "string",
        "receiver_city": "string",
        "receiver_state_id": 0,
        "receiver_country_id": 0,
        "receiver_phone": "string",
        "receiver_activity": "string",
        "receiver_postalcode": "string",
        "payment_conditions": "string",
        "currency_id": 0,
        "exchange_rate_value": 0,
        "sale_modality": 0,
        "sale_clause": 0,
        "transportation_doc_type": 0,
        "transportation_doc_billing": 0,
        "document_status": 0
    },
    "details": [
        {
            "quantity": 0,
            "line_description": "string",
            "unit_measure": "string",
            "unit_price": 0,
            "long_description": "string",
            "modifier_amount": 0,
            "total_taxes": 0,
            "modifier_percentage": 0,
            "total_amount_line": 0
        }
    ],
    "totals": {
        "net_amount": 0,
        "taxes_amount": 0,
        "total_amount": 0
    },
    "electronic_document": {
        "document_xml": "string",
        "document_pdf": "string",
        "stamp_img": "string",
        "document_transfer_copy_pdf": "string"
    },
    "payment_link": {
        "payment_url": "string"
    },
    "result": {
        "status": 0,
        "error_message": "string"
    }
}

Responses

Document updated successfully