{"openapi":"3.1.0","info":{"title":"MoochFacturación · referencia inicial","version":"1.0.0","description":"Seis operaciones seleccionadas. El servidor indicado es TEST, conectado a SIFEN de pruebas; la credencial la entrega Mooch. OAuth se documenta en la guía y no está incluido en este contrato del Core."},"servers":[{"url":"https://fe-test.moochsoft.com","description":"TEST (SIFEN de pruebas). Sin valor fiscal."}],"tags":[{"name":"Documents","description":"Issue electronic documents and read them back. Issuing is asynchronous: `202` means the document was durably accepted, not that SIFEN approved it. Follow `status` until it is final."},{"name":"Artifacts","description":"The signed XML and the KuDE PDF of a document, once they exist."},{"name":"Fiscal events","description":"Cancellations and numbering inutilizations. Each one is an event with its own lifecycle, separate from the document."},{"name":"Capabilities","description":"What this credential can do today: the document types, artifacts and fiscal events offered, and whether a contributor is ready to emit."},{"name":"Exports","description":"Asynchronous, read-only packages with a contributor’s documents, for accounting and audit."},{"name":"Webhooks","description":"HTTPS endpoints that receive document and fiscal event changes, signed with a secret you keep."},{"name":"Contributors","description":"The taxpayers you issue for: registration, issuer profile (RUC, timbrado, address) and establishment/point pairs."},{"name":"Numbering","description":"Which document types a contributor can issue and how each series of numbers is configured."},{"name":"Signing credential","description":"The contributor’s digital certificate, handed to custody once. It is never returned."},{"name":"Authentication","description":"Exchange an application assertion for a short-lived access token."},{"name":"Service accounts","description":"Credentials of your own systems. A credential is shown once, when it is issued."},{"name":"Integrator credentials","description":"Credentials an authorized application issues for a customer’s system, limited to documents and artifacts of one contributor."}],"x-tagGroups":[{"name":"Issue documents","tags":["Documents","Artifacts","Fiscal events","Capabilities","Webhooks","Exports"]},{"name":"Set up contributors","tags":["Contributors","Numbering","Signing credential"]},{"name":"Access","tags":["Authentication","Service accounts","Integrator credentials"]}],"paths":{"/v1/capabilities":{"get":{"operationId":"getCapabilities","tags":["Capabilities"],"summary":"Get capabilities","description":"The document types, artifacts and fiscal events this deployment offers to your credential, and the `environment` it serves (`TEST` or `PRODUCTION`). Read it once at start-up instead of assuming.","security":[{"serviceAccount":[]}],"x-required-scope":"documents:read","parameters":[],"responses":{"200":{"description":"Successful response","headers":{"X-Request-Id":{"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}},"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["requestId","environment","documentTypes","artifacts","fiscalEvents"],"properties":{"requestId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"environment":{"type":"string","enum":["TEST","PRODUCTION"]},"documentTypes":{"type":"array","items":{"type":"string","enum":["FE","NCE","NDE","AFE","NRE"]},"minItems":1,"maxItems":5},"artifacts":{"type":"array","items":{"type":"string","enum":["SIGNED_XML","KUDE_PDF"]},"minItems":1,"maxItems":2},"fiscalEvents":{"type":"array","items":{"type":"string","enum":["CANCELLATION","INUTILIZATION"]},"maxItems":2}}}}}},"401":{"description":"The credential is missing, invalid, expired or revoked.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"403":{"description":"The credential does not carry the scope this operation needs, or cannot reach the contributor.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"429":{"description":"Too many requests. Wait `Retry-After` seconds.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer","minimum":1}}},"content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"500":{"description":"Unexpected error. When the operation creates something, repeat it with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"503":{"description":"Temporarily unavailable. Repeat later with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}}}},"/v1/contributors/{contributorId}/readiness":{"get":{"operationId":"getContributorReadiness","tags":["Capabilities"],"summary":"Get contributor readiness","description":"Machine-readable checks, with the blockers that stop a contributor from issuing and the status of its access to Production.","security":[{"serviceAccount":[]}],"x-required-scope":"readiness:read","parameters":[{"in":"path","name":"contributorId","required":true,"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}],"responses":{"200":{"description":"Get contributor readiness","headers":{"X-Request-Id":{"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}},"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["requestId","contributorId","environment","ready","checks","blockers","productionAccess"],"properties":{"requestId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"contributorId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"environment":{"type":"string","enum":["TEST","PRODUCTION"]},"ready":{"type":"boolean"},"checks":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","outcome","reasonCode","checkedAt"],"properties":{"kind":{"type":"string"},"outcome":{"type":"string"},"reasonCode":{"anyOf":[{"type":"string"},{"type":"null"}]},"checkedAt":{"type":"string","format":"date-time"}}}},"blockers":{"type":"array","items":{"type":"object","additionalProperties":false,"required":["kind","code"],"properties":{"kind":{"type":"string"},"code":{"type":"string"}}}},"productionAccess":{"type":"object","additionalProperties":false,"required":["status","updatedAt"],"properties":{"status":{"type":"string","enum":["ENABLED","DISABLED","SUSPENDED"]},"updatedAt":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}]}}}}}}}},"400":{"description":"The request is malformed or a field is invalid. `errors[]` names each field.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"401":{"description":"The credential is missing, invalid, expired or revoked.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"403":{"description":"The credential does not carry the scope this operation needs, or cannot reach the contributor.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"404":{"description":"The resource does not exist or is not reachable with this credential.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"429":{"description":"Too many requests. Wait `Retry-After` seconds.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer","minimum":1}}},"content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"500":{"description":"Unexpected error. When the operation creates something, repeat it with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"503":{"description":"Temporarily unavailable. Repeat later with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}}}},"/v1/documents":{"post":{"operationId":"createDocument","tags":["Documents"],"summary":"Create a document","description":"Issues an electronic invoice (`documentType: \"FE\"`). The issuer and the timbrado come from the contributor profile, never from the body. A rule that cannot be decided exactly (quantization, rounding, payment totals, advances, State-entity receivers) answers `422 validation_error` with the rule id and no value. `202` is durable acceptance, not fiscal approval: read the document until its `status` is final. Always send an `Idempotency-Key`; repeating the call with the same key and body returns the same document, and the same key with another body is `409 idempotency_conflict`. A credit note (`documentType: \"NCE\"`) names its `sourceDocumentId`, `motive` and `credit.scope` (`TOTAL` or `PARTIAL`, with `items`). The source must be an approved invoice of the same contributor with a current attestation; the note credits at most what the invoice invoiced, in its own currency, cumulatively. A source problem answers `not_found`, `source_unsupported`, `source_ineligible`, `source_lineage_unverified` or `credit_limit_exceeded`.","security":[{"serviceAccount":[]}],"x-required-scope":"documents:write","parameters":[{"in":"header","name":"Idempotency-Key","required":true,"schema":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[\\x21-\\x7e]+$"}},{"in":"header","name":"X-Correlation-Id","required":false,"schema":{"type":"string","minLength":1,"maxLength":128}}],"responses":{"202":{"description":"Durably accepted, or the replay of an earlier identical request","headers":{"X-Request-Id":{"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}},"Location":{"schema":{"type":"string"}},"Idempotent-Replayed":{"description":"Present, with the value `true`, when the answer repeats an earlier request with the same `Idempotency-Key`; no document was created by this call.","schema":{"type":"string","const":"true"}}},"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["requestId","documentId","contributorId","documentType","environment","status","createdAt","updatedAt","externalReference","cdc","operationalCondition","officialResult"],"properties":{"requestId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"documentId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"contributorId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"documentType":{"type":"string","enum":["FE","NCE","NDE","AFE","NRE"]},"environment":{"type":"string","enum":["TEST","PRODUCTION"]},"status":{"type":"string","enum":["ACCEPTED","VALIDATION_FAILED","PENDING","PROCESSING","UNKNOWN","APPROVED","APPROVED_WITH_OBSERVATION","REJECTED"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"externalReference":{"anyOf":[{"type":"string"},{"type":"null"}]},"cdc":{"anyOf":[{"type":"string"},{"type":"null"}]},"operationalCondition":{"anyOf":[{"type":"string","enum":["NEEDS_RECOVERY"]},{"type":"null"}]},"officialResult":{"anyOf":[{"type":"null"},{"type":"object","additionalProperties":false,"required":["outcome","evidenceSha256"],"properties":{"outcome":{"type":"string","enum":["APPROVED","APPROVED_WITH_OBSERVATION","REJECTED"]},"evidenceSha256":{"type":"string","pattern":"^[0-9a-f]{64}$"}}}]},"sourceDocument":{"type":"object","additionalProperties":false,"required":["documentId","cdc"],"properties":{"documentId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"cdc":{"type":"string","pattern":"^[0-9]{44}$"}}},"officialResponse":{"type":"object","additionalProperties":false,"required":["receivedAt","state","results"],"properties":{"receivedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"state":{"anyOf":[{"type":"string"},{"type":"null"}]},"results":{"type":"array","maxItems":20,"items":{"type":"object","additionalProperties":false,"required":["code","message"],"properties":{"code":{"type":"string","pattern":"^[0-9]{4}$"},"message":{"type":"string","maxLength":300}}}}}},"sendFailure":{"type":"object","additionalProperties":false,"required":["reason","message","occurredAt","retryable"],"properties":{"reason":{"type":"string","enum":["DOCUMENT_TYPE_NOT_ENABLED","SIGNER_NOT_UPDATED","SIGNING_CREDENTIAL_UNAVAILABLE","INVALID_FOR_SIGNING","PRE_EFFECT_FAILED","SIGNER_DID_NOT_COMPLETE"]},"message":{"type":"string","maxLength":200},"occurredAt":{"type":"string","format":"date-time"},"retryable":{"type":"boolean"}}},"receiverEvents":{"type":"array","maxItems":50,"items":{"type":"object","additionalProperties":false,"required":["id","kind","observedAt","signedAt","reason","conformity","receivedAt","receiverName","sifenEventId","protocol"],"properties":{"id":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"kind":{"type":"string","enum":["RECEIPT_NOTICE","CONFORMITY","DISCONFORMITY","UNAWARENESS"]},"observedAt":{"type":"string","format":"date-time"},"signedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"reason":{"anyOf":[{"type":"string"},{"type":"null"}]},"conformity":{"anyOf":[{"type":"string","enum":["TOTAL","PARTIAL"]},{"type":"null"}]},"receivedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"receiverName":{"anyOf":[{"type":"string"},{"type":"null"}]},"sifenEventId":{"anyOf":[{"type":"string"},{"type":"null"}]},"protocol":{"anyOf":[{"type":"string"},{"type":"null"}]}}}},"cancellation":{"type":"object","additionalProperties":false,"required":["fiscalEventId","status","requestedAt","updatedAt","operationalCondition","retryable"],"properties":{"fiscalEventId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"status":{"type":"string","enum":["ACCEPTED","VALIDATION_FAILED","PENDING","PROCESSING","UNKNOWN","APPROVED","APPROVED_WITH_OBSERVATION","REJECTED"]},"requestedAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"operationalCondition":{"anyOf":[{"type":"string","enum":["NEEDS_RECOVERY"]},{"type":"null"}]},"retryable":{"type":"boolean"}}}}}}}},"400":{"description":"The request is malformed or a field is invalid. `errors[]` names each field.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"401":{"description":"The credential is missing, invalid, expired or revoked.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"403":{"description":"The credential does not carry the scope this operation needs, or cannot reach the contributor.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"409":{"description":"The request conflicts with the current state or with an earlier use of the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"413":{"description":"The body is larger than the operation accepts.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"415":{"description":"The body is not `application/json`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"422":{"description":"The request is well formed but a rule was not met. `code` says which; `errors[]` names the field and rule.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"429":{"description":"Too many requests. Wait `Retry-After` seconds.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer","minimum":1}}},"content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"500":{"description":"Unexpected error. When the operation creates something, repeat it with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"503":{"description":"Temporarily unavailable. Repeat later with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}},"requestBody":{"required":true,"content":{"application/json":{"schema":{"oneOf":[{"type":"object","additionalProperties":false,"required":["contributorId","documentType","document"],"properties":{"contributorId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"documentType":{"type":"string","const":"FE"},"document":{"type":"object","required":["operation","receiver","condition","items"],"properties":{"operation":{"type":"object","additionalProperties":false,"required":["transactionType","presence","currency"],"description":"How the operation took place and in which currency.","properties":{"transactionType":{"type":"string","enum":["1","2","3"],"description":"`1` sale of goods, `2` provision of services, `3` both."},"presence":{"type":"string","enum":["1","2","3","4","5","6","9"],"description":"Presence indicator: `1` in person, `2` electronic, `3` telemarketing, `4` home sale, `5` banking, `6` cyclical, `9` other (then `presenceOther` is required)."},"presenceOther":{"type":"string","minLength":10,"maxLength":30,"description":"Free text. Only, and always, when `presence` is `9`."},"currency":{"type":"string","pattern":"^[A-Z]{3}$","description":"ISO 4217 currency code, for example `PYG` or `USD`."},"exchangeRate":{"type":"object","additionalProperties":false,"required":["mode"],"description":"Exchange rate. Present exactly when `currency` is not `PYG`.","properties":{"mode":{"type":"string","enum":["GLOBAL","PER_ITEM"],"description":"`GLOBAL` uses `rate` for the whole document; `PER_ITEM` takes `exchangeRate` from each item."},"rate":{"type":"string","pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Guaraníes per unit of currency, up to 4 decimals. Present exactly when `mode` is `GLOBAL`. A decimal in a string, with no sign, exponent or separators."}}}}},"receiver":{"type":"object","required":["kind"],"properties":{"kind":{"type":"string","enum":["CONTRIBUTOR","NON_CONTRIBUTOR","UNNAMED","FOREIGN"]}}},"condition":{"type":"object","required":["type"],"properties":{"type":{"type":"string","enum":["CASH","CREDIT"]}}},"items":{"type":"array","minItems":1,"maxItems":999,"items":{"type":"object","additionalProperties":false,"required":["code","description","unit","quantity","unitPrice","vat"],"properties":{"code":{"type":"string","minLength":1,"maxLength":50,"description":"Your code for the product or service."},"description":{"type":"string","minLength":1,"maxLength":2000},"unit":{"type":"string","description":"Unit of measure code from the SIFEN catalog, for example `77` for unit."},"quantity":{"type":"string","pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Greater than 0, up to 8 decimals. A decimal in a string, with no sign, exponent or separators."},"unitPrice":{"type":"string","pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Price of one unit in the document currency, greater than 0, up to 8 decimals. A decimal in a string, with no sign, exponent or separators."},"discount":{"type":"string","pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Discount per unit in the document currency, up to 8 decimals. A decimal in a string, with no sign, exponent or separators."},"exchangeRate":{"type":"string","pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Rate of this item, up to 4 decimals. Present exactly when `operation.exchangeRate.mode` is `PER_ITEM`. A decimal in a string, with no sign, exponent or separators."},"vat":{"type":"object","additionalProperties":false,"required":["type"],"description":"VAT treatment of the item.","properties":{"type":{"type":"string","enum":["TAXED","EXONERATED","EXEMPT","PARTIAL"],"description":"`TAXED` is taxed in full; `PARTIAL` is taxed on part of its value (`taxedPercent`); `EXONERATED` and `EXEMPT` carry no VAT."},"rate":{"type":"string","enum":["5","10"],"description":"Percentage. Required for `TAXED` and `PARTIAL`; not allowed otherwise."},"taxedPercent":{"type":"string","pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Percentage of the value that is taxed, greater than 0 and less than 100, up to 8 decimals. Only, and always, for `PARTIAL`. A decimal in a string, with no sign, exponent or separators."}}}}}},"globalDiscountPercent":{"type":"string","pattern":"^(0|[1-9][0-9]*)(\\.[0-9]+)?$","description":"Informative global discount percentage, up to 8 decimals; it drives the per-item discount. A decimal in a string, with no sign, exponent or separators."},"transport":{"type":"object","additionalProperties":false,"required":["mode","freightResponsible"],"description":"Transport of the goods, optional. An export carries its Incoterm and destination here.","properties":{"type":{"type":"string","enum":["1","2"],"description":"`1` own, `2` third party."},"mode":{"type":"string","enum":["1","2","3","4"],"description":"`1` land, `2` river, `3` air, `4` multimodal."},"freightResponsible":{"type":"string","enum":["1","2","3","4","5"],"description":"`1` issuer, `2` receiver, `3` third party, `4` intermediary agent, `5` own transport."},"incoterm":{"type":"string","enum":["CFR","CIF","CIP","CPT","DAP","DAT","DDP","EXW","FAS","FCA","FOB"]},"manifest":{"type":"string","minLength":1,"maxLength":15,"description":"Number of the manifest, bill of lading, transit declaration or waybill."},"startDate":{"type":"string","format":"date","description":"Start of the transport. `endDate` is required with it."},"endDate":{"type":"string","format":"date","description":"End of the transport, not before `startDate`."},"destinationCountry":{"type":"string","pattern":"^[A-Z]{3}$","description":"ISO 3166-1 alpha-3 code of the destination."}}}},"description":"The invoice. Amounts are strings so no precision is lost; the server computes totals and VAT, and rejects a rule it cannot decide exactly (quantization, rounding, advances) with `422 validation_error`, the rule id and no value."},"presentation":{"type":"object","additionalProperties":false,"properties":{"logo":{"type":"object","additionalProperties":false,"required":["mediaType","data"],"properties":{"mediaType":{"type":"string","enum":["image/png","image/jpeg"]},"data":{"type":"string","minLength":4,"maxLength":65536}}},"accentColor":{"type":"string","pattern":"^#[0-9a-f]{6}$"},"note":{"type":"string","minLength":1,"maxLength":500},"format":{"type":"string","enum":["a4","ticket-80","ticket-58"]}}},"externalReference":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[^\\u0000-\\u001f\\u007f]+$"}}},{"type":"object","additionalProperties":false,"required":["contributorId","documentType","sourceDocumentId","document"],"properties":{"contributorId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"documentType":{"type":"string","const":"NCE"},"sourceDocumentId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"document":{"type":"object","required":["motive","credit"],"properties":{"motive":{"type":"string","pattern":"^[1-8]$"},"credit":{"type":"object","required":["scope"],"properties":{"scope":{"type":"string","enum":["TOTAL","PARTIAL"]},"items":{"type":"array","minItems":1,"maxItems":999,"items":{"type":"object"}}}}}},"presentation":{"type":"object","additionalProperties":false,"properties":{"logo":{"type":"object","additionalProperties":false,"required":["mediaType","data"],"properties":{"mediaType":{"type":"string","enum":["image/png","image/jpeg"]},"data":{"type":"string","minLength":4,"maxLength":65536}}},"accentColor":{"type":"string","pattern":"^#[0-9a-f]{6}$"},"note":{"type":"string","minLength":1,"maxLength":500},"format":{"type":"string","enum":["a4","ticket-80","ticket-58"]}}},"externalReference":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[^\\u0000-\\u001f\\u007f]+$"}}},{"type":"object","additionalProperties":false,"required":["contributorId","documentType","sourceDocumentId","document"],"properties":{"contributorId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"documentType":{"type":"string","const":"NDE"},"sourceDocumentId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"document":{"type":"object"},"presentation":{"type":"object","additionalProperties":false,"properties":{"logo":{"type":"object","additionalProperties":false,"required":["mediaType","data"],"properties":{"mediaType":{"type":"string","enum":["image/png","image/jpeg"]},"data":{"type":"string","minLength":4,"maxLength":65536}}},"accentColor":{"type":"string","pattern":"^#[0-9a-f]{6}$"},"note":{"type":"string","minLength":1,"maxLength":500},"format":{"type":"string","enum":["a4","ticket-80","ticket-58"]}}},"externalReference":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[^\\u0000-\\u001f\\u007f]+$"}}},{"type":"object","additionalProperties":false,"required":["contributorId","documentType","document"],"properties":{"contributorId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"documentType":{"type":"string","const":"AFE"},"document":{"type":"object"},"presentation":{"type":"object","additionalProperties":false,"properties":{"logo":{"type":"object","additionalProperties":false,"required":["mediaType","data"],"properties":{"mediaType":{"type":"string","enum":["image/png","image/jpeg"]},"data":{"type":"string","minLength":4,"maxLength":65536}}},"accentColor":{"type":"string","pattern":"^#[0-9a-f]{6}$"},"note":{"type":"string","minLength":1,"maxLength":500},"format":{"type":"string","enum":["a4","ticket-80","ticket-58"]}}},"externalReference":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[^\\u0000-\\u001f\\u007f]+$"}}},{"type":"object","additionalProperties":false,"required":["contributorId","documentType","document"],"properties":{"contributorId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"documentType":{"type":"string","const":"NRE"},"sourceDocumentId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"document":{"type":"object"},"presentation":{"type":"object","additionalProperties":false,"properties":{"logo":{"type":"object","additionalProperties":false,"required":["mediaType","data"],"properties":{"mediaType":{"type":"string","enum":["image/png","image/jpeg"]},"data":{"type":"string","minLength":4,"maxLength":65536}}},"accentColor":{"type":"string","pattern":"^#[0-9a-f]{6}$"},"note":{"type":"string","minLength":1,"maxLength":500},"format":{"type":"string","enum":["a4","ticket-80","ticket-58"]}}},"externalReference":{"type":"string","minLength":1,"maxLength":128,"pattern":"^[^\\u0000-\\u001f\\u007f]+$"}}}]}}}}}},"/v1/documents/{documentId}":{"get":{"operationId":"getDocument","tags":["Documents"],"summary":"Get a document","description":"Reads one document: its `status`, the official SIFEN result when there is one, and the CDC once it exists. Poll this until `status` is final (`APPROVED`, `APPROVED_WITH_OBSERVATION`, `REJECTED` or `VALIDATION_FAILED`). `UNKNOWN` means the outcome is not known yet; do not issue the document again.","security":[{"serviceAccount":[]}],"x-required-scope":"documents:read","parameters":[{"in":"path","name":"documentId","required":true,"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}],"responses":{"200":{"description":"Successful response","headers":{"X-Request-Id":{"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}},"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["requestId","documentId","contributorId","documentType","environment","status","createdAt","updatedAt","externalReference","cdc","operationalCondition","officialResult"],"properties":{"requestId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"documentId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"contributorId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"documentType":{"type":"string","enum":["FE","NCE","NDE","AFE","NRE"]},"environment":{"type":"string","enum":["TEST","PRODUCTION"]},"status":{"type":"string","enum":["ACCEPTED","VALIDATION_FAILED","PENDING","PROCESSING","UNKNOWN","APPROVED","APPROVED_WITH_OBSERVATION","REJECTED"]},"createdAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"externalReference":{"anyOf":[{"type":"string"},{"type":"null"}]},"cdc":{"anyOf":[{"type":"string"},{"type":"null"}]},"operationalCondition":{"anyOf":[{"type":"string","enum":["NEEDS_RECOVERY"]},{"type":"null"}]},"officialResult":{"anyOf":[{"type":"null"},{"type":"object","additionalProperties":false,"required":["outcome","evidenceSha256"],"properties":{"outcome":{"type":"string","enum":["APPROVED","APPROVED_WITH_OBSERVATION","REJECTED"]},"evidenceSha256":{"type":"string","pattern":"^[0-9a-f]{64}$"}}}]},"sourceDocument":{"type":"object","additionalProperties":false,"required":["documentId","cdc"],"properties":{"documentId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"cdc":{"type":"string","pattern":"^[0-9]{44}$"}}},"officialResponse":{"type":"object","additionalProperties":false,"required":["receivedAt","state","results"],"properties":{"receivedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"state":{"anyOf":[{"type":"string"},{"type":"null"}]},"results":{"type":"array","maxItems":20,"items":{"type":"object","additionalProperties":false,"required":["code","message"],"properties":{"code":{"type":"string","pattern":"^[0-9]{4}$"},"message":{"type":"string","maxLength":300}}}}}},"sendFailure":{"type":"object","additionalProperties":false,"required":["reason","message","occurredAt","retryable"],"properties":{"reason":{"type":"string","enum":["DOCUMENT_TYPE_NOT_ENABLED","SIGNER_NOT_UPDATED","SIGNING_CREDENTIAL_UNAVAILABLE","INVALID_FOR_SIGNING","PRE_EFFECT_FAILED","SIGNER_DID_NOT_COMPLETE"]},"message":{"type":"string","maxLength":200},"occurredAt":{"type":"string","format":"date-time"},"retryable":{"type":"boolean"}}},"receiverEvents":{"type":"array","maxItems":50,"items":{"type":"object","additionalProperties":false,"required":["id","kind","observedAt","signedAt","reason","conformity","receivedAt","receiverName","sifenEventId","protocol"],"properties":{"id":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"kind":{"type":"string","enum":["RECEIPT_NOTICE","CONFORMITY","DISCONFORMITY","UNAWARENESS"]},"observedAt":{"type":"string","format":"date-time"},"signedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"reason":{"anyOf":[{"type":"string"},{"type":"null"}]},"conformity":{"anyOf":[{"type":"string","enum":["TOTAL","PARTIAL"]},{"type":"null"}]},"receivedAt":{"anyOf":[{"type":"string"},{"type":"null"}]},"receiverName":{"anyOf":[{"type":"string"},{"type":"null"}]},"sifenEventId":{"anyOf":[{"type":"string"},{"type":"null"}]},"protocol":{"anyOf":[{"type":"string"},{"type":"null"}]}}}},"cancellation":{"type":"object","additionalProperties":false,"required":["fiscalEventId","status","requestedAt","updatedAt","operationalCondition","retryable"],"properties":{"fiscalEventId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"status":{"type":"string","enum":["ACCEPTED","VALIDATION_FAILED","PENDING","PROCESSING","UNKNOWN","APPROVED","APPROVED_WITH_OBSERVATION","REJECTED"]},"requestedAt":{"type":"string","format":"date-time"},"updatedAt":{"type":"string","format":"date-time"},"operationalCondition":{"anyOf":[{"type":"string","enum":["NEEDS_RECOVERY"]},{"type":"null"}]},"retryable":{"type":"boolean"}}}}}}}},"400":{"description":"The request is malformed or a field is invalid. `errors[]` names each field.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"401":{"description":"The credential is missing, invalid, expired or revoked.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"403":{"description":"The credential does not carry the scope this operation needs, or cannot reach the contributor.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"404":{"description":"The resource does not exist or is not reachable with this credential.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"429":{"description":"Too many requests. Wait `Retry-After` seconds.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer","minimum":1}}},"content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"500":{"description":"Unexpected error. When the operation creates something, repeat it with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"503":{"description":"Temporarily unavailable. Repeat later with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}}}},"/v1/documents/{documentId}/artifacts":{"get":{"operationId":"listArtifacts","tags":["Artifacts"],"summary":"List the artifacts of a document","description":"The artifacts a document has so far (`SIGNED_XML`, `KUDE_PDF`), each with its `stage` (`SIGNED` or `FINAL`), media type, size and SHA-256.","security":[{"serviceAccount":[]}],"x-required-scope":"artifacts:read","parameters":[{"in":"path","name":"documentId","required":true,"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}],"responses":{"200":{"description":"Successful response","headers":{"X-Request-Id":{"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}},"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["requestId","artifacts"],"properties":{"requestId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"artifacts":{"type":"array","maxItems":2,"items":{"type":"object","additionalProperties":false,"required":["kind","stage","mediaType","sha256","byteLength"],"properties":{"kind":{"type":"string","enum":["SIGNED_XML","KUDE_PDF"]},"stage":{"type":"string","enum":["SIGNED","FINAL"],"description":"SIGNED: published right after signing, before SIFEN answers (provisional, the document may still be rejected). FINAL: with the captured SIFEN response; it replaces the signed one."},"mediaType":{"type":"string"},"sha256":{"type":"string","pattern":"^[0-9a-f]{64}$"},"byteLength":{"type":"integer","minimum":1,"maximum":1000000}}}}}}}}},"400":{"description":"The request is malformed or a field is invalid. `errors[]` names each field.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"401":{"description":"The credential is missing, invalid, expired or revoked.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"403":{"description":"The credential does not carry the scope this operation needs, or cannot reach the contributor.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"404":{"description":"The resource does not exist or is not reachable with this credential.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"429":{"description":"Too many requests. Wait `Retry-After` seconds.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer","minimum":1}}},"content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"500":{"description":"Unexpected error. When the operation creates something, repeat it with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"503":{"description":"Temporarily unavailable. Repeat later with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}}}},"/v1/documents/{documentId}/artifacts/{kind}":{"get":{"operationId":"downloadArtifact","tags":["Artifacts"],"summary":"Download an artifact","description":"Downloads one artifact: `SIGNED_XML` as `application/xml`, `KUDE_PDF` as `application/pdf`. The bytes are re-verified against the recorded SHA-256 before they are sent; a mismatch is an integrity failure, never a regenerated file.","security":[{"serviceAccount":[]}],"x-required-scope":"artifacts:read","parameters":[{"in":"path","name":"documentId","required":true,"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}},{"in":"path","name":"kind","required":true,"schema":{"type":"string","enum":["SIGNED_XML","KUDE_PDF"]}}],"responses":{"200":{"description":"Successful response","headers":{"X-Request-Id":{"schema":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"}}},"content":{"application/xml":{"schema":{"type":"string","format":"binary"}},"application/pdf":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"The request is malformed or a field is invalid. `errors[]` names each field.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"401":{"description":"The credential is missing, invalid, expired or revoked.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"403":{"description":"The credential does not carry the scope this operation needs, or cannot reach the contributor.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"404":{"description":"The resource does not exist or is not reachable with this credential.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"429":{"description":"Too many requests. Wait `Retry-After` seconds.","headers":{"Retry-After":{"description":"Seconds to wait before retrying.","schema":{"type":"integer","minimum":1}}},"content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"500":{"description":"Unexpected error. When the operation creates something, repeat it with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}},"503":{"description":"Temporarily unavailable. Repeat later with the same `Idempotency-Key`.","content":{"application/problem+json":{"schema":{"$ref":"#/components/schemas/Problem"}}}}}}}},"components":{"securitySchemes":{"serviceAccount":{"type":"http","scheme":"bearer","description":"The credential of a service account (`mf_test_…`) or an application access token (`mf_app_…`), sent as `Authorization: Bearer <credential>`. It carries scopes; an operation lists the one it needs in `x-required-scope`."}},"schemas":{"Problem":{"type":"object","additionalProperties":false,"required":["type","title","status","code","detail","requestId","retryable"],"properties":{"type":{"type":"string","format":"uri"},"title":{"type":"string"},"status":{"type":"integer"},"code":{"type":"string","enum":["invalid_request","validation_error","invalid_credential","forbidden","not_found","method_not_allowed","idempotency_conflict","resource_state_conflict","not_ready","unsupported_capability","source_unsupported","source_ineligible","source_lineage_unverified","credit_limit_exceeded","quota_exceeded","payload_too_large","unsupported_media_type","rate_limited","temporarily_unavailable","acceptance_outcome_unknown","artifact_integrity_failure"]},"detail":{"type":"string"},"requestId":{"type":"string","pattern":"^[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"},"retryable":{"type":"boolean"},"errors":{"type":"array","maxItems":20,"items":{"type":"object","additionalProperties":false,"required":["field","code","message"],"properties":{"field":{"type":"string"},"code":{"type":"string"},"ruleId":{"type":"string"},"message":{"type":"string"}}}}}}}}}