{"openapi":"3.1.0","info":{"title":"Abreno API","version":"1.0.0","summary":"Facturas certificadas pela AGT (FE/436/AGT/2026), proformas, recibos e notas, a partir do seu programa.","description":"Guia de integração: https://abreno.app/desenvolvedores/integracao · Referência: https://abreno.app/desenvolvedores. Os valores são em kwanzas; os preços das linhas sem IVA; as datas AAAA-MM-DD (Luanda). As mensagens de erro vêm em português, para mostrar a quem usa. O mesmo serviço como servidor MCP: https://abreno.app/mcp (sandbox: /sandbox/mcp).","contact":{"name":"Abreno","url":"https://abreno.app/desenvolvedores"}},"servers":[{"url":"https://abreno.app/v1","description":"Produção"}],"security":[{"apiKey":[]}],"tags":[{"name":"Conta","description":"A chave e os seus emitentes."},{"name":"Emitentes","description":"As empresas em nome de quem emite."},{"name":"Documentos","description":"Facturas, recibos e notas certificados pela AGT."},{"name":"Proformas","description":"Orçamentos sem valor fiscal, que passam a factura."},{"name":"Relatórios"}],"paths":{"/me":{"get":{"tags":["Conta"],"operationId":"me","summary":"Quem é a chave, o ambiente e os emitentes","responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Me"}}}},"401":{"$ref":"#/components/responses/E401"},"429":{"$ref":"#/components/responses/E429"}}}},"/issuers":{"post":{"tags":["Emitentes"],"operationId":"createIssuer","summary":"Ligar uma empresa (parceiros)","description":"Sandbox: cria uma empresa de teste (201); um NIF acabado em 0000 espera consentimento (202, código 1234). Produção: uma empresa que já factura pelo Abreno autoriza na consola (202 pending_consent); uma que ainda não está no Abreno recebe uma inscrição (202 enrolling, com onboarding_url). Uma chave da própria empresa recebe 403 OWN_COMPANY_ONLY.","parameters":[{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewIssuer"}}}},"responses":{"201":{"description":"Pronto a emitir (sandbox).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Issuer"}}}},"202":{"description":"À espera de consentimento ou inscrição.","content":{"application/json":{"schema":{"oneOf":[{"$ref":"#/components/schemas/Issuer"},{"$ref":"#/components/schemas/Enrollment"}]}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"403":{"$ref":"#/components/responses/E403"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/issuers/{id}":{"get":{"tags":["Emitentes"],"operationId":"getIssuer","summary":"O estado de um emitente","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O emitente (issuer_id)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Issuer"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/issuers/{id}/consent":{"post":{"tags":["Emitentes"],"operationId":"consent","summary":"Consentimento com código (só sandbox)","description":"Em produção o dono autoriza na consola Abreno: 409 CONSENT_IN_CONSOLE.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O emitente (issuer_id)."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["code"],"properties":{"code":{"type":"string","examples":["1234"]}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Issuer"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/issuers/{id}/sandbox":{"put":{"tags":["Emitentes"],"operationId":"sandboxAgt","summary":"O que a AGT «responde» a este emitente (só sandbox)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O emitente (issuer_id)."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["agt"],"properties":{"agt":{"type":"string","enum":["valid","rejected","unreachable"]}}}}}},"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Issuer"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/issuers/{id}/documents":{"post":{"tags":["Documentos"],"operationId":"issueDocument","summary":"Emitir um documento","description":"FT (a pagar depois: nome e NIF do cliente), FR (pago agora), e os tipos especiais (FA, FG, GF, AC, AF, RP, RA, CS, LD). Os recibos e notas emitem-se sobre o documento.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O emitente (issuer_id)."},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewDocument"}}}},"responses":{"201":{"description":"Emitido.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"500":{"$ref":"#/components/responses/E500"}}}},"/issuers/{id}/saft":{"get":{"tags":["Relatórios"],"operationId":"saft","summary":"O SAF-T (AO) do período, em XML","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O emitente (issuer_id)."},{"name":"from","in":"query","required":true,"schema":{"type":"string","format":"date"}},{"name":"to","in":"query","required":true,"schema":{"type":"string","format":"date"}}],"responses":{"200":{"description":"SAF-T (AO).","content":{"application/xml":{"schema":{"type":"string"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/issuers/{id}/proformas":{"post":{"tags":["Proformas"],"operationId":"createProforma","summary":"Criar uma proforma","description":"Um orçamento sem valor fiscal, numerado PF ano/n, válido 30 dias. As linhas são verificadas como numa factura: taxas de IVA de Angola e o regime da empresa.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O emitente (issuer_id)."},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewProforma"}}}},"responses":{"201":{"description":"Criada.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Proforma"}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}},"get":{"tags":["Proformas"],"operationId":"listProformas","summary":"As proformas feitas com esta chave","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O emitente (issuer_id)."},{"name":"status","in":"query","schema":{"type":"string","enum":["open","invoiced","cancelled"]}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"proformas":{"type":"array","items":{"$ref":"#/components/schemas/Proforma"}}}}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/documents/{id}":{"get":{"tags":["Documentos"],"operationId":"getDocument","summary":"Um documento, o estado na AGT e o que falta pagar","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O documento (document_id)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/documents/{id}/pdf":{"get":{"tags":["Documentos"],"operationId":"documentPdf","summary":"O PDF (Original, depois 2.ª via)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O documento (document_id)."}],"responses":{"200":{"description":"O PDF (A4).","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/documents/{id}/receipts":{"post":{"tags":["Documentos"],"operationId":"receipt","summary":"Recibo de um pagamento (RC numa FT, AR num AC, RG numa GF)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O documento (document_id)."},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"amount":{"type":"number","exclusiveMinimum":0,"description":"O valor pago; sem ele, tudo o que falta."},"issued_by":{"$ref":"#/components/schemas/IssuedBy"}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"500":{"$ref":"#/components/responses/E500"}}}},"/documents/{id}/credit-notes":{"post":{"tags":["Documentos"],"operationId":"creditNote","summary":"Nota de crédito: anular ou rectificar","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O documento (document_id)."},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["kind","reason","buyer_ack"],"properties":{"kind":{"type":"string","enum":["anulacao","rectificacao"]},"reason":{"type":"string","maxLength":200},"buyer_ack":{"type":"object","required":["method","reference"],"properties":{"method":{"type":"string","enum":["email","signed_copy"]},"reference":{"type":"string","maxLength":200}}},"lines":{"type":"array","items":{"$ref":"#/components/schemas/Line"},"description":"Numa rectificação: o que se credita."},"issued_by":{"$ref":"#/components/schemas/IssuedBy"}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"500":{"$ref":"#/components/responses/E500"}}}},"/documents/{id}/debit-notes":{"post":{"tags":["Documentos"],"operationId":"debitNote","summary":"Nota de débito: despesas pagas em nome do cliente, sem IVA","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O documento (document_id)."},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["reason","lines"],"properties":{"reason":{"type":"string","maxLength":200},"lines":{"type":"array","items":{"$ref":"#/components/schemas/Line"}},"issued_by":{"$ref":"#/components/schemas/IssuedBy"}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"500":{"$ref":"#/components/responses/E500"}}}},"/documents/{id}/reissue":{"post":{"tags":["Documentos"],"operationId":"reissue","summary":"Emitir de novo um documento que a AGT recusou","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"O documento (document_id)."},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"buyer":{"$ref":"#/components/schemas/Buyer"},"lines":{"type":"array","items":{"$ref":"#/components/schemas/Line"}},"issued_by":{"$ref":"#/components/schemas/IssuedBy"}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"500":{"$ref":"#/components/responses/E500"}}}},"/proformas/{id}":{"get":{"tags":["Proformas"],"operationId":"getProforma","summary":"Uma proforma","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"A proforma (proforma_id)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Proforma"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/proformas/{id}/pdf":{"get":{"tags":["Proformas"],"operationId":"proformaPdf","summary":"O PDF da proforma, «não serve de factura»","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"A proforma (proforma_id)."}],"responses":{"200":{"description":"O PDF (A4).","content":{"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/proformas/{id}/invoice":{"post":{"tags":["Proformas"],"operationId":"invoiceProforma","summary":"Facturar a proforma: FT ou FR com as mesmas linhas","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"A proforma (proforma_id)."},{"$ref":"#/components/parameters/IdempotencyKey"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","properties":{"type":{"type":"string","enum":["FT","FR"],"default":"FT"},"due_date":{"type":"string","format":"date","description":"FT: o vencimento, de hoje a um ano."},"issued_by":{"$ref":"#/components/schemas/IssuedBy"}}}}}},"responses":{"201":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Document"}}}},"400":{"$ref":"#/components/responses/E400"},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"},"500":{"$ref":"#/components/responses/E500"}}}},"/proformas/{id}/cancel":{"post":{"tags":["Proformas"],"operationId":"cancelProforma","summary":"Anular uma proforma aberta","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"A proforma (proforma_id)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Proforma"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"409":{"$ref":"#/components/responses/E409"},"429":{"$ref":"#/components/responses/E429"}}}},"/enrollments/{id}":{"get":{"tags":["Emitentes"],"operationId":"getEnrollment","summary":"Uma inscrição (parceiros, produção)","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string","format":"uuid"},"description":"A inscrição (enrollment_id)."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Enrollment"}}}},"401":{"$ref":"#/components/responses/E401"},"404":{"$ref":"#/components/responses/E404"},"429":{"$ref":"#/components/responses/E429"}}}},"/usage":{"get":{"tags":["Relatórios"],"operationId":"usage","summary":"Documentos e SMS do mês, por emitente","parameters":[{"name":"month","in":"query","schema":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"},"description":"AAAA-MM; por omissão, o mês corrente."}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"type":"object","properties":{"month":{"type":"string"},"issuers":{"type":"array","items":{"type":"object","properties":{"issuer_id":{"type":"string"},"documents":{"type":"object","additionalProperties":{"type":"integer"}},"sms":{"type":"integer"}}}}}}}}},"401":{"$ref":"#/components/responses/E401"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}},"/statement":{"get":{"tags":["Relatórios"],"operationId":"statement","summary":"A parte de um distribuidor (10%) dos planos pagos no mês","parameters":[{"name":"month","in":"query","schema":{"type":"string","pattern":"^\\d{4}-(0[1-9]|1[0-2])$"}}],"responses":{"200":{"description":"OK","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Statement"}}}},"401":{"$ref":"#/components/responses/E401"},"422":{"$ref":"#/components/responses/E422"},"429":{"$ref":"#/components/responses/E429"}}}}},"components":{"securitySchemes":{"apiKey":{"type":"http","scheme":"bearer","description":"Authorization: Bearer abreno_live_…. A empresa cria a chave na consola (Conectores › API Abreno); um parceiro recebe-a do Abreno."}},"parameters":{"IdempotencyKey":{"name":"Idempotency-Key","in":"header","required":true,"schema":{"type":"string","maxLength":100},"description":"O id do pedido do seu lado. A mesma chave e o mesmo corpo dão a mesma resposta sem duplicar; com outro corpo, 409 IDEMPOTENCY_CONFLICT. Só os sucessos ficam guardados."}},"responses":{"E400":{"description":"Pedido mal formado ou sem Idempotency-Key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E401":{"description":"Chave em falta, inválida ou de outro ambiente.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E403":{"description":"A chave não pode fazer isto.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E404":{"description":"Não existe, ou não é desta chave.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E409":{"description":"O estado não o permite (consentimento, acesso retirado, proforma fechada, idempotência).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E422":{"description":"O conteúdo: linhas, taxas, cliente, valores, regras fiscais.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E429":{"description":"Mais de 120 pedidos por minuto nesta chave.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"E500":{"description":"Falha do Abreno: repita com a mesma Idempotency-Key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}},"schemas":{"Error":{"type":"object","required":["error","message"],"properties":{"error":{"type":"string","examples":["BUYER_REQUIRED"]},"message":{"type":"string","description":"Em português, para mostrar a quem usa."}}},"Buyer":{"type":"object","properties":{"nif":{"type":"string","pattern":"^[0-9A-Z]{9,14}$","description":"Obrigatório numa FT, GF, AC e AF."},"name":{"type":"string","maxLength":200},"address":{"type":"string","maxLength":300},"country":{"type":"string","pattern":"^[A-Z]{2}$","default":"AO"}}},"Line":{"type":"object","required":["description","quantity","unit_price","tax_rate"],"properties":{"description":{"type":"string","maxLength":200},"quantity":{"type":"number","exclusiveMinimum":0,"maximum":1000000},"unit":{"type":"string","maxLength":10,"default":"UN"},"unit_price":{"type":"number","minimum":0,"description":"Sem IVA, em kwanzas."},"tax_rate":{"type":"number","description":"Taxa de IVA (14, 7, 5 ou 0). Nunca é assumida."},"exemption_code":{"type":"string","description":"Código de isenção da AGT (ex.: M13), obrigatório com IVA a 0%."},"kind":{"type":"string","enum":["product","service"]},"product_code":{"type":"string","maxLength":60},"operation_date":{"type":"string","format":"date","description":"O dia do fornecimento, quando não é o do documento (FG)."}}},"ProformaLine":{"allOf":[{"$ref":"#/components/schemas/Line"},{"type":"object","properties":{"discount_pct":{"type":"number","minimum":0,"maximum":99,"description":"Desconto na linha, em %."}}}]},"IssuedBy":{"type":"object","properties":{"partner_user_id":{"type":"string","maxLength":100},"name":{"type":"string","maxLength":120}},"description":"Quem, no seu programa, pediu o documento."},"NewDocument":{"type":"object","required":["type","lines","issued_by"],"properties":{"type":{"type":"string","enum":["FT","FR","FA","FG","GF","AC","AF","RP","RA","CS","LD"]},"buyer":{"$ref":"#/components/schemas/Buyer"},"lines":{"type":"array","minItems":1,"maxItems":30,"items":{"$ref":"#/components/schemas/Line"}},"due_date":{"type":"string","format":"date","description":"FT: o vencimento, de hoje a um ano."},"reference":{"type":"string","maxLength":60,"description":"FT/FR: a referência do cliente (V/ Ref.), impressa."},"notes":{"type":"string","maxLength":500,"description":"FT/FR: observações, impressas."},"withholding":{"type":"array","maxItems":5,"description":"Só numa AF: a retenção que o comprador faz.","items":{"type":"object","required":["type","amount"],"properties":{"type":{"type":"string"},"description":{"type":"string"},"amount":{"type":"number","exclusiveMinimum":0}}}},"issued_by":{"$ref":"#/components/schemas/IssuedBy"}}},"Document":{"type":"object","properties":{"document_id":{"type":"string","format":"uuid"},"type":{"type":"string","examples":["FT"]},"number":{"type":"string","examples":["FT SFT2026/12"]},"series":{"type":"string"},"hash4":{"type":"string","description":"Os 4 caracteres da assinatura impressos no documento."},"qr_url":{"type":"string"},"issued_at":{"type":"string","format":"date-time"},"buyer":{"$ref":"#/components/schemas/Buyer"},"gross_total":{"type":"number"},"withholding_total":{"type":"number","description":"O que o cliente retém: numa FT ou FG de serviços de uma empresa a uma empresa, 6,5% sem IVA (Imposto Industrial, art. 67.º)."},"total_in_words":{"type":"string"},"contingency":{"type":"boolean"},"agt_status":{"type":"string","enum":["pending","registered","valid","rejected","contingency","failed"]},"agt_errors":{"type":"array","items":{"type":"object"}},"pdf_url":{"type":"string","description":"Link público do PDF."},"relates_to":{"type":"object","properties":{"document_id":{"type":"string"},"number":{"type":"string"}}},"receipts":{"type":"array","items":{"type":"object","properties":{"document_id":{"type":"string"},"number":{"type":"string"},"gross_total":{"type":"number"}}}},"debit_notes":{"type":"array","items":{"type":"object"}},"credit_notes":{"type":"array","items":{"type":"object"}},"reissued_as":{"type":"object","properties":{"document_id":{"type":"string"},"number":{"type":"string"}}},"due":{"type":"number","description":"FT, AC, GF: o que ainda falta pagar (o total, menos a retenção, os recibos e as notas de crédito)."}}},"NewProforma":{"type":"object","required":["lines"],"properties":{"buyer":{"allOf":[{"$ref":"#/components/schemas/Buyer"},{"type":"object","properties":{"phone":{"type":"string"}}}]},"lines":{"type":"array","minItems":1,"maxItems":30,"items":{"$ref":"#/components/schemas/ProformaLine"}},"reference":{"type":"string","maxLength":60,"description":"A referência do cliente: o seu documento (ex.: a nota de cobrança)."},"notes":{"type":"string","maxLength":500}}},"Proforma":{"type":"object","properties":{"proforma_id":{"type":"string","format":"uuid"},"number":{"type":"string","examples":["PF 2026/7"]},"status":{"type":"string","enum":["open","invoiced","cancelled"]},"issued_on":{"type":"string","format":"date"},"valid_until":{"type":"string","format":"date"},"buyer":{"$ref":"#/components/schemas/Buyer"},"reference":{"type":["string","null"]},"notes":{"type":["string","null"]},"lines":{"type":"array","items":{"allOf":[{"$ref":"#/components/schemas/ProformaLine"},{"type":"object","properties":{"net":{"type":"number","description":"A linha sem IVA, já com o desconto."}}}]}},"total":{"type":"number","description":"Com IVA."},"invoice_number":{"type":["string","null"]}}},"NewIssuer":{"type":"object","required":["nif"],"properties":{"nif":{"type":"string"},"legal_name":{"type":"string"},"address":{"type":"string"},"issuer_kind":{"type":"string","enum":["company","individual_with_activity","licensed_vendor"]},"iva_regime":{"type":"string","enum":["geral","simplificado","exclusao"]},"phone":{"type":"string","description":"Telemóvel do dono (+244…)."},"establishment":{"type":"object","properties":{"name":{"type":"string"},"address":{"type":"string"}}}}},"Issuer":{"type":"object","properties":{"issuer_id":{"type":"string","format":"uuid"},"ready":{"type":"boolean"},"status":{"type":"string","enum":["linked","pending_consent","revoked"]},"sandbox":{"type":"object","properties":{"agt":{"type":"string"}}},"checks":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"done":{"type":"boolean"},"by":{"type":"string"}}}}}},"Enrollment":{"type":"object","properties":{"enrollment_id":{"type":"string","format":"uuid"},"status":{"type":"string","enum":["enrolling","signed_up","linked","expired"]},"onboarding_url":{"type":"string"},"expires_at":{"type":"string","format":"date-time"},"issuer_id":{"type":"string"}}},"Me":{"type":"object","properties":{"partner":{"type":"string"},"kind":{"type":"string","enum":["distributor","consumer"]},"environment":{"type":"string","enum":["sandbox","production"]},"issuers":{"type":"array","items":{"$ref":"#/components/schemas/Issuer"}}}},"Statement":{"type":"object","properties":{"month":{"type":"string"},"share":{"type":"number"},"paid_kz":{"type":"number"},"share_kz":{"type":"number"},"payments":{"type":"array","items":{"type":"object","properties":{"company":{"type":"string"},"plan":{"type":"string"},"months":{"type":"integer"},"paid_at":{"type":"string"},"amount_kz":{"type":"number"},"share_kz":{"type":"number"}}}}}}}},"webhooks":{"event":{"post":{"summary":"Eventos do Abreno para o seu programa","description":"Enviados para o endereço de eventos da chave, assinados: Abreno-Signature: t=<unix>,v1=<hex HMAC-SHA256 de «<t>.<corpo>» com o segredo de eventos>. Recuse t com mais de 5 minutos; podem chegar repetidos (event_id) e fora de ordem (occurred_at). Responda 2xx.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["event_id","type","occurred_at"],"properties":{"event_id":{"type":"string"},"type":{"type":"string","enum":["document.issued","document.agt_status","issuer.status"]},"occurred_at":{"type":"string","format":"date-time"},"issuer_id":{"type":"string"},"document_id":{"type":"string"},"number":{"type":"string"},"agt_status":{"type":"string"},"document":{"$ref":"#/components/schemas/Document"},"idempotency_key":{"type":"string"}}}}}},"responses":{"200":{"description":"Recebido."}}}}}}