Emitir comprobante de retención
const url = 'https://api.chaski.ec/v1/withholdings';const options = { method: 'POST', headers: { 'Idempotency-Key': 'example', Authorization: 'Bearer <token>', 'Content-Type': 'application/json' }, body: '{"issuer":"example","emission_point":"example","external_ref":"example","subject":{"id_type":"ruc","id":"example","name":"example","email":"[email protected]","kind":"natural_person","related_party":true},"fiscal_period":"example","documents":[{"support_code":"example","type":"example","number":"example","issue_date":"example","accounting_date":"example","authorization_number":"example","foreign_payment":{"regime":"general","country":"example","double_taxation_treaty":true,"subject_to_withholding":true,"preferential_regime":true},"subtotal":"example","total":"example","taxes":[{"type":"iva","rate":"0","base":"example","amount":"example"}],"withholdings":[{"tax":"income","code":"example","base":"example","rate":"example"}],"payments":[{"method":"no_financial_system","amount":"example"}]}],"additional_info":{"additionalProperty":"example"},"metadata":{"additionalProperty":"example"},"send_email":true}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.chaski.ec/v1/withholdings \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --header 'Idempotency-Key: example' \ --data '{ "issuer": "example", "emission_point": "example", "external_ref": "example", "subject": { "id_type": "ruc", "id": "example", "name": "example", "email": "[email protected]", "kind": "natural_person", "related_party": true }, "fiscal_period": "example", "documents": [ { "support_code": "example", "type": "example", "number": "example", "issue_date": "example", "accounting_date": "example", "authorization_number": "example", "foreign_payment": { "regime": "general", "country": "example", "double_taxation_treaty": true, "subject_to_withholding": true, "preferential_regime": true }, "subtotal": "example", "total": "example", "taxes": [ { "type": "iva", "rate": "0", "base": "example", "amount": "example" } ], "withholdings": [ { "tax": "income", "code": "example", "base": "example", "rate": "example" } ], "payments": [ { "method": "no_financial_system", "amount": "example" } ] } ], "additional_info": { "additionalProperty": "example" }, "metadata": { "additionalProperty": "example" }, "send_email": true }'Comprobante de retención (07), esquema 2.0.0. El emisor es el agente de retención y subject el proveedor al que se le retiene (no puede ser consumidor final; con id_type: "foreign" hay que indicar kind). Cada documento de sustento lleva sus impuestos, sus retenciones y sus pagos, que deben sumar total. El valor retenido se calcula (base × porcentaje). En IVA el porcentaje sale del código (1 30 %, 2 70 %, 3 100 %, 9 10 %, 10 20 %, 11 50 %, 7 y 8 0 %) y la base no puede pasar del IVA del documento; en renta e ISD el porcentaje es obligatorio y en renta la base no puede pasar del subtotal. Responde 202 con status: "pending" y se notifica con withholding.authorized o withholding.rejected. En producción consume cuota igual que una factura (402 quota_exceeded).
Authorizations
Sección titulada «Authorizations»Parameters
Sección titulada «Parameters»Header Parameters
Sección titulada «Header Parameters»Una clave única por petición (por ejemplo un UUID). Vale 24 h: reintentar con la misma clave y el mismo body devuelve la misma respuesta.
Request Bodyrequired
Sección titulada «Request Bodyrequired»object
object
object
object
object
object
object
object
Responses
Sección titulada «Responses»OK
object
Clave de acceso de 49 dígitos
object
object
object
object
object
Example
{ "id": "wht_01jbx3k9q2f8m4tn6vwz0yh5ce", "status": "pending", "environment": "test", "emission_point": "001-003", "number": "001-003-000000009", "fiscal_period": "2026-11", "documents": [ { "type": "01", "number": "001-001-000000123", "withholdings": [ { "tax": "income", "code": "312", "rate": "1.75" } ] } ]}Petición inválida
object
object
Example
{ "error": { "code": "invalid_request" }}Falta la API key o no es válida
object
object
Example
{ "error": { "code": "invalid_request" }}Cuota de comprobantes agotada (quota_exceeded)
object
object
Example
{ "error": { "code": "invalid_request" }}Sin permiso (cuenta suspendida, emisor no habilitado en producción, límite del plan…)
object
object
Example
{ "error": { "code": "invalid_request" }}No se puede procesar (certificado vencido, Idempotency-Key reutilizada…)
object
object
Example
{ "error": { "code": "invalid_request" }}Demasiadas peticiones
object
object
Example
{ "error": { "code": "invalid_request" }}