ES | EN

📄 MIPYME Documents

Create a new document

POST
Endpoint URL https://api-billing.koywe.com/V1/documents
Requires authentication

Authentication

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

Parameters

NameLocationTypeRequiredDescription
generate_stampqueryintegerGenerate the stamp image file (where applicable)

Request body (example)

{
    "options": {
        "draft_only": 0,
        "draft_preview": 0,
        "send_email": 1,
        "template_id": 0,
        "gross_values": "1",
        "rounding_type": "net",
        "company_web": "https://www.company.com/",
        "company_email": "[email protected]",
        "pdf_transfer_copy": 1
    },
    "header": {
        "account_id": "141",
        "document_type_id": "2",
        "document_sequence_code": "F001",
        "issue_date": "string",
        "document_number": 0,
        "issuer_tax_id_code": "string",
        "issuer_tax_id_type": "string",
        "issuer_legal_name": "string",
        "issuer_address": "string",
        "issuer_district": "string",
        "issuer_city": "string",
        "issuer_country_id": "string",
        "issuer_phone": "string",
        "issuer_activity": "string",
        "issuer_postalcode": "string",
        "receiver_tax_id_code": "11111111-1",
        "receiver_tax_id_type": "string",
        "receiver_legal_name": "string",
        "receiver_address": "string",
        "receiver_district": "string",
        "receiver_city": "string",
        "receiver_phone": "string",
        "receiver_activity": "string",
        "receiver_postalcode": "string",
        "receiver_state_id": 0,
        "receiver_county_id": "string",
        "receiver_country_id": 0,
        "receiver_email": "string",
        "payment_conditions": "string",
        "seller_id": 0,
        "currency_id": 0,
        "exchange_rate_value": 0,
        "service_indicator": 0,
        "sale_modality": 0,
        "sale_clause": 0,
        "guide_type": 0,
        "transfer_type": 0,
        "branch_office_code": "string",
        "observations": "string",
        "deployment_observations": 0,
        "port_disembarkation": "string",
        "port_embarkation": "string",
        "gross_weight": "string",
        "shipping_address": "string",
        "additional": {
            "mx_header": {
                "receiver_cfdi_usage": "string"
            },
            "mx_shipping": {
                "distance": "100",
                "transport_code": "01",
                "transport_method_name": "Autotransporte",
                "transport_tax_id_type": "MX-RFC",
                "transport_tax_id_code": "EKU9003173C9",
                "transport_license": "a234567890",
                "origin": {
                    "tax_id_type": "...",
                    "tax_id_code": "...",
                    "date_time": "...",
                    "address_state_id": "...",
                    "address_country_id": "...",
                    "address_postalcode": "..."
                },
                "destination": {
                    "tax_id_type": "...",
                    "tax_id_code": "...",
                    "date_time": "...",
                    "address_state_id": "...",
                    "address_country_id": "...",
                    "address_postalcode": "..."
                },
                "merchandise": {
                    "total_weight": "...",
                    "sct_permission_code": "...",
                    "sct_permission_number": "...",
                    "vehicle_configuration": "...",
                    "vehicle_weight": "...",
                    "vehicle_license_plate": "...",
                    "vehicle_year": "...",
                    "insurance_company": "...",
                    "insurance_identifier": "...",
                    "details": "..."
                }
            },
            "mx_exports": {
                "terms": "FOB",
                "exchange_rate": 20.6708,
                "total": 1624,
                "origin": {
                    "address_street": "...",
                    "address_city_id": "...",
                    "address_county_id": "...",
                    "address_state_id": "...",
                    "address_country_id": "...",
                    "address_postalcode": "..."
                },
                "destination": {
                    "tax_id_type": "...",
                    "tax_id_code": "...",
                    "address_street": "...",
                    "address_state_id": "...",
                    "address_country_id": "...",
                    "address_postalcode": "..."
                },
                "merchandise": {
                    "details": "..."
                }
            },
            "co_header": {
                "reported_payment_code": 0
            },
            "pe_header": {
                "operation_type": "string"
            },
            "ar_header": {
                "invoice_concept": 0,
                "items_quantity": 0,
                "service_date_from": "string",
                "service_date_to": "string",
                "receiver_vat_condition_id": "string"
            },
            "pe_retention_header": {
                "pe_sunat_retention_system_code": "string",
                "pe_sunat_retention_percent": 0,
                "pe_sunat_total_paid": 0
            },
            "pe_shipping": {
                "handling_code": "string",
                "special_instructions": 0,
                "handling_instructions": "string",
                "gross_weight_measure": "string",
                "gross_weight_measure_id": "string",
                "shipment_stage": {
                    "transport_mode_code": "...",
                    "transit_period": "...",
                    "driver_person": "...",
                    "carrier_party": "..."
                },
                "delivery": {
                    "delivery_address": "...",
                    "dispatch": "..."
                },
                "transport_handling_unit": {
                    "transport_equipment_id": "..."
                }
            }
        }
    },
    "details": [
        {
            "quantity": 0,
            "sku": "string",
            "line_description": "string",
            "unit_price": 0,
            "long_description": "string",
            "unit_measure": "string",
            "modifier_amount": 0,
            "modifier_percentage": 0,
            "total_taxes": 0,
            "total_amount_line": 0,
            "taxes": [
                {
                    "tax_type_id": "...",
                    "tax_percentage": "...",
                    "tax_amount": "..."
                }
            ],
            "additional": {
                "mx_detail": {
                    "product_service_identifier": "...",
                    "measure_unit_code": "..."
                }
            }
        }
    ],
    "references": [
        {
            "document_type_id": 0,
            "reference_type": 0,
            "reference_number": "string",
            "reference_document_id": 0,
            "reference_code": 0,
            "description": "string",
            "reference_date": "string",
            "additional": {
                "pe_retention_details": {
                    "reference_paid_amount": "...",
                    "reference_total_invoice_amount": "...",
                    "reference_paid_date": "...",
                    "reference_payment_id": "...",
                    "pe_reference_sunat_retention_amount": "...",
                    "pe_reference_sunat_retention_date": "...",
                    "calculation_rate": "...",
                    "currency_id": "..."
                }
            }
        }
    ],
    "globals_discounts_surcharges": [
        {
            "discount_surcharge_code": "string",
            "discount_surcharge_value": 0,
            "discount_surcharge_type": "string"
        }
    ],
    "totals": {
        "vat_credit_construction_company": 0,
        "net_amount": 0,
        "taxes_amount": 0,
        "total_amount": 0
    },
    "payment_link": {
        "payment_url": "string"
    }
}

Responses

Document created successfully