biterp

Update invoice

Only provided fields are changed. Field editability depends on invoice state: queued for fiscal transmission rejects every field; issued (transmitted) accepts only internal_notes and metadata; for Brazilian tenants, a finalized invoice without an invoices_br_data row is treated the same as issued (only internal_notes and metadata); an invoice originated from a sales order additionally rejects product_type, salesperson_name, fiscal_notes, discount_amount, discount_rate, and structural line item changes - fiscal fields (taxes, br_data, us_data) stay editable pre-transmission regardless of sales-order origin.

PATCH
/invoices/{id}
AuthorizationBearer <token>

In: header

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

application/json

application/json

application/json

curl -X PATCH "https://api.biterp.ai/invoices/{id}" \  -H "Content-Type: application/json" \  -d '{}'
{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "record_number": 0,
  "reference_code": "string",
  "status": "draft",
  "operation_type": "sale",
  "product_type": "string",
  "origin": "internal",
  "has_source_xml": true,
  "source_data_import_id": "b4400733-2a6b-44b7-8c73-e4b6d1fbc8cc",
  "customer_id": "160c0c4b-9966-4dc1-a916-8407eb10d74e",
  "customer": {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "legal_name": "string",
    "trade_name": "string",
    "tax_id": "string",
    "tax_id_type": "CPF",
    "country_code": "string"
  },
  "invoice_date": "2019-08-24",
  "origin_state_code": "string",
  "origin_country_code": "string",
  "destination_state_code": "string",
  "destination_country_code": "string",
  "customer_tax_type": "individual",
  "salesperson_name": "string",
  "fiscal_notes": "string",
  "internal_notes": "string",
  "discount_amount": "string",
  "discount_rate": "string",
  "tax_engine_provider": "string",
  "sales_order_id": "5e95a238-d0d8-4280-92bc-08d83c9c12a6",
  "subtotal": "string",
  "items_discount": "string",
  "total_discount": "string",
  "total_tax": "string",
  "withheld_total": "string",
  "net_receivable_total": "string",
  "total": "string",
  "items": [
    {
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "invoice_id": "f4c4edb8-11e0-4b33-bcc1-482dc59ebb32",
      "product_id": "0d012afa-f885-4e65-aeca-37e27701e2d1",
      "sales_order_item_id": "0d4e920a-487c-47f5-9954-1e8d46c8c6a6",
      "item_description": "string",
      "quantity": "string",
      "unit_price": "string",
      "discount_amount": "string",
      "po_number": "string",
      "subtotal": "string",
      "total": "string",
      "position": 0,
      "tax_resolution_id": "46335649-8ed5-4e65-adbe-1d06bb8bf9d7",
      "br_data": {
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "invoice_item_id": "a018106e-4ca4-4a01-ab85-3af044b569c5",
        "ncm_code": "string",
        "cest_code": "string",
        "federal_service_code": "string",
        "city_service_code": "string",
        "nbs_code": "string",
        "cnae_code": "string",
        "ibs_cbs_cst": "string",
        "ibs_cbs_classification": "string",
        "ibs_cbs_operation_indicator_code": "string",
        "ibs_cbs_is_personal_use": true,
        "cfop": "string"
      },
      "us_data": {
        "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
        "invoice_item_id": "a018106e-4ca4-4a01-ab85-3af044b569c5",
        "hts_code": "string",
        "tax_code": "string",
        "sales_tax_category": "string"
      },
      "deleted_at": "2019-08-24T14:15:22Z"
    }
  ],
  "taxes": [
    {
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "invoice_id": "f4c4edb8-11e0-4b33-bcc1-482dc59ebb32",
      "invoice_item_id": "a018106e-4ca4-4a01-ab85-3af044b569c5",
      "tax_code": "string",
      "tax_name": "string",
      "base_amount": "string",
      "rate": "string",
      "amount": "string",
      "jurisdiction": "string",
      "is_withheld": true,
      "is_included": true,
      "source": "string",
      "position": 0,
      "deleted_at": "2019-08-24T14:15:22Z"
    }
  ],
  "br_data": {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "invoice_id": "f4c4edb8-11e0-4b33-bcc1-482dc59ebb32",
    "nfse_number": "string",
    "nfse_series": "string",
    "declaration_number": "string",
    "declaration_series": "string",
    "nfse_verification_code": "string",
    "nfse_access_key": "string",
    "source_xml_dialect": "nacional",
    "operation_nature": "string",
    "fiscal_emission_date": "2019-08-24",
    "provider_status": "string",
    "transmission_status": "queued",
    "taxation_type": "string",
    "external_invoice_id": "string",
    "cancel_justification": "string",
    "cancel_processing_status": "pending",
    "cancel_processing_message": "string",
    "processing_status": "string",
    "processing_code": "string",
    "processing_message": "string",
    "submission_xml": "string",
    "response_xml": "string",
    "url": "string",
    "cancel_access_key": "string",
    "receiver_name": "string",
    "receiver_federal_tax_number": "string",
    "receiver_email": "string",
    "receiver_phone": "string",
    "receiver_address_street": "string",
    "receiver_address_number": "string",
    "receiver_address_district": "string",
    "receiver_address_postal_code": "string",
    "receiver_address_additional_information": "string",
    "receiver_city_ibge_code": "string",
    "receiver_city_name": "string",
    "receiver_state_code": "string",
    "receiver_municipal_registration": "string",
    "receiver_state_registration": "string",
    "receiver_state_registration_exempt": true,
    "transmission_readiness": {
      "ready": true,
      "blockers": [
        "wrong_item_count"
      ]
    },
    "auto_transmission_status": "pending",
    "auto_transmission_message": "string",
    "auto_transmission_queued_at": "2019-08-24T14:15:22Z",
    "auto_transmission_last_attempt_at": "2019-08-24T14:15:22Z",
    "auto_transmission_next_retry_at": "2019-08-24T14:15:22Z",
    "auto_transmission_attempt_count": 0
  },
  "us_data": {
    "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
    "invoice_id": "f4c4edb8-11e0-4b33-bcc1-482dc59ebb32",
    "net_terms": 0
  },
  "warnings": [
    {
      "item_id": "4d8cd62e-a579-4dae-af8c-3172f96f8f7c",
      "item_index": 0,
      "code": "stale_tax_resolution",
      "message": "string",
      "changed_fields": [
        {
          "entity": "product",
          "field": "string",
          "snapshot_value": {},
          "current_value": {}
        }
      ],
      "tax_resolution_id": "46335649-8ed5-4e65-adbe-1d06bb8bf9d7"
    }
  ],
  "deleted_by_user_id": "e06321af-43d5-4340-818b-555f83254c47",
  "created_at": "2019-08-24T14:15:22Z",
  "updated_at": "2019-08-24T14:15:22Z",
  "deleted_at": "2019-08-24T14:15:22Z"
}
{
  "status_code": 422,
  "message": "Could not resolve provided geography fields",
  "error": "Unprocessable Entity",
  "details": {
    "fields": {
      "country_code": [
        "Could not resolve country from '1112' (tried ISO2, ISO3, numeric code and names)"
      ],
      "city": [
        "Could not resolve city from 'CidadeQueNaoExiste' in country 'BR'"
      ]
    }
  }
}
{
  "status_code": 404,
  "message": "Customer not found",
  "error": "Not Found",
  "code": "CUSTOMER_NOT_FOUND"
}
{
  "status_code": 404,
  "message": "Customer not found",
  "error": "Not Found",
  "code": "CUSTOMER_NOT_FOUND"
}
{
  "status_code": 404,
  "message": "Customer not found",
  "error": "Not Found",
  "code": "CUSTOMER_NOT_FOUND"
}
{
  "status_code": 422,
  "message": "Could not resolve provided geography fields",
  "error": "Unprocessable Entity",
  "details": {
    "fields": {
      "country_code": [
        "Could not resolve country from '1112' (tried ISO2, ISO3, numeric code and names)"
      ],
      "city": [
        "Could not resolve city from 'CidadeQueNaoExiste' in country 'BR'"
      ]
    }
  }
}
{
  "status_code": 404,
  "message": "Customer not found",
  "error": "Not Found",
  "code": "CUSTOMER_NOT_FOUND"
}