{"openapi":"3.1.0","info":{"title":"Buscador de notas","summary":"Notas de entrada (NF-e 55, NFS-e e CT-e) por certificado A1.","description":"Guia de integração: [/](/). Toda rota de `/v1` exige o cabeçalho `X-API-Key`.","version":"0.1.0"},"paths":{"/health":{"get":{"tags":["health"],"summary":"Health","operationId":"health_health_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"additionalProperties":{"type":"string"},"type":"object","title":"Response Health Health Get"}}}}}}},"/health/ready":{"get":{"tags":["health"],"summary":"Ready","description":"For the external monitor: database, Redis and a live worker.","operationId":"ready_health_ready_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}}}}},"/v1/certificates/public-key":{"get":{"tags":["certificates"],"summary":"Get Public Key","operationId":"get_public_key_v1_certificates_public_key_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/PublicKey"}}}}},"security":[{"APIKeyHeader":[]}]}},"/v1/certificates":{"get":{"tags":["certificates"],"summary":"List Certificates","operationId":"list_certificates_v1_certificates_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/CertificateOut"},"type":"array","title":"Response List Certificates V1 Certificates Get"}}}}},"security":[{"APIKeyHeader":[]}]},"post":{"tags":["certificates"],"summary":"Create Certificate","operationId":"create_certificate_v1_certificates_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/NewCertificate"}}},"required":true},"responses":{"201":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/CertificateOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/v1/certificates/{serial_number}/sources":{"put":{"tags":["certificates"],"summary":"Update Sources","operationId":"update_sources_v1_certificates__serial_number__sources_put","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"serial_number","in":"path","required":true,"schema":{"type":"string","title":"Serial Number"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SourcesUpdate"}}}},"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/certificates/{serial_number}/manifest":{"put":{"tags":["certificates"],"summary":"Update Manifest","operationId":"update_manifest_v1_certificates__serial_number__manifest_put","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"serial_number","in":"path","required":true,"schema":{"type":"string","title":"Serial Number"}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ManifestUpdate"}}}},"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/certificates/{serial_number}":{"delete":{"tags":["certificates"],"summary":"Delete Certificate","operationId":"delete_certificate_v1_certificates__serial_number__delete","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"serial_number","in":"path","required":true,"schema":{"type":"string","title":"Serial Number"}}],"responses":{"204":{"description":"Successful Response"},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/documents/search":{"post":{"tags":["documents"],"summary":"Search Documents","operationId":"search_documents_v1_documents_search_post","requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchRequest"}}},"required":true},"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/SearchResponse"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}},"security":[{"APIKeyHeader":[]}]}},"/v1/documents/{identifier}":{"get":{"tags":["documents"],"summary":"Read Document","operationId":"read_document_v1_documents__identifier__get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"identifier","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Identifier"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"$ref":"#/components/schemas/DocumentOut"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/documents/{identifier}/xml":{"get":{"tags":["documents"],"summary":"Read Document Xml","operationId":"read_document_xml_v1_documents__identifier__xml_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"identifier","in":"path","required":true,"schema":{"type":"string","format":"uuid","title":"Identifier"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}},"/v1/status":{"get":{"tags":["documents"],"summary":"Read Status","operationId":"read_status_v1_status_get","responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"items":{"$ref":"#/components/schemas/CompanyStatusOut"},"type":"array","title":"Response Read Status V1 Status Get"}}}}},"security":[{"APIKeyHeader":[]}]}},"/v1/runs":{"get":{"tags":["runs"],"summary":"List Runs","description":"What each query cycle did, newest first. Only companies the product can see.","operationId":"list_runs_v1_runs_get","security":[{"APIKeyHeader":[]}],"parameters":[{"name":"cnpj","in":"query","required":false,"schema":{"anyOf":[{"type":"string","minLength":14,"maxLength":14},{"type":"null"}],"title":"Cnpj"}},{"name":"source","in":"query","required":false,"schema":{"anyOf":[{"type":"string","pattern":"^(nfe|nfse|cte)$"},{"type":"null"}],"title":"Source"}},{"name":"status","in":"query","required":false,"schema":{"anyOf":[{"type":"string","pattern":"^(ok|blocked|error)$"},{"type":"null"}],"title":"Status"}},{"name":"limit","in":"query","required":false,"schema":{"type":"integer","maximum":200,"minimum":1,"default":50,"title":"Limit"}}],"responses":{"200":{"description":"Successful Response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/RunOut"},"title":"Response List Runs V1 Runs Get"}}}},"422":{"description":"Validation Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"CertificateGroupOut":{"properties":{"serial_number":{"type":"string","title":"Serial Number"},"cnpj":{"type":"string","title":"Cnpj"},"company_name":{"type":"string","title":"Company Name"},"certificate_active":{"type":"boolean","title":"Certificate Active"},"last_success":{"additionalProperties":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}]},"type":"object","title":"Last Success"},"documents":{"items":{"$ref":"#/components/schemas/DocumentOut"},"type":"array","title":"Documents"},"next_cursor":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Next Cursor"},"has_more":{"type":"boolean","title":"Has More"}},"type":"object","required":["serial_number","cnpj","company_name","certificate_active","last_success","documents","next_cursor","has_more"],"title":"CertificateGroupOut"},"CertificateOut":{"properties":{"serial_number":{"type":"string","title":"Serial Number"},"cnpj":{"type":"string","title":"Cnpj"},"valid_until":{"type":"string","format":"date-time","title":"Valid Until"},"active":{"type":"boolean","title":"Active"}},"type":"object","required":["serial_number","cnpj","valid_until","active"],"title":"CertificateOut"},"CompanyStatusOut":{"properties":{"cnpj":{"type":"string","title":"Cnpj"},"company_name":{"type":"string","title":"Company Name"},"state":{"type":"string","title":"State"},"auto_manifest":{"type":"boolean","title":"Auto Manifest"},"manifest_active":{"type":"boolean","title":"Manifest Active"},"serial_number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Serial Number"},"certificate_valid_until":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Certificate Valid Until"},"sources":{"items":{"$ref":"#/components/schemas/SourceStatus"},"type":"array","title":"Sources"},"alerts":{"items":{"type":"string"},"type":"array","title":"Alerts"},"summaries_without_xml":{"type":"integer","title":"Summaries Without Xml"},"failed_manifests":{"type":"integer","title":"Failed Manifests"},"unreadable_items":{"type":"integer","title":"Unreadable Items"}},"type":"object","required":["cnpj","company_name","state","auto_manifest","manifest_active","serial_number","certificate_valid_until","sources","alerts","summaries_without_xml","failed_manifests","unreadable_items"],"title":"CompanyStatusOut"},"DocumentOut":{"properties":{"id":{"type":"string","format":"uuid","title":"Id"},"cnpj":{"type":"string","title":"Cnpj"},"doc_type":{"type":"string","title":"Doc Type"},"access_key":{"type":"string","title":"Access Key"},"status":{"type":"string","title":"Status"},"manifest_status":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Manifest Status"},"manifest_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Manifest Error"},"issuer_id":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Issuer Id"},"issuer_name":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Issuer Name"},"number":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Number"},"amount_cents":{"anyOf":[{"type":"integer"},{"type":"null"}],"title":"Amount Cents"},"issued_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Issued At"},"created_at":{"type":"string","format":"date-time","title":"Created At"},"changed_at":{"type":"string","format":"date-time","title":"Changed At"},"has_xml":{"type":"boolean","title":"Has Xml"},"xml":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Xml"}},"type":"object","required":["id","cnpj","doc_type","access_key","status","manifest_status","manifest_error","issuer_id","issuer_name","number","amount_cents","issued_at","created_at","changed_at","has_xml"],"title":"DocumentOut"},"HTTPValidationError":{"properties":{"detail":{"items":{"$ref":"#/components/schemas/ValidationError"},"type":"array","title":"Detail"}},"type":"object","title":"HTTPValidationError"},"ManifestUpdate":{"properties":{"enabled":{"type":"boolean","title":"Enabled"}},"type":"object","required":["enabled"],"title":"ManifestUpdate"},"NewCertificate":{"properties":{"kid":{"type":"string","maxLength":32,"title":"Kid"},"encrypted_key":{"type":"string","maxLength":2000,"title":"Encrypted Key"},"nonce":{"type":"string","maxLength":64,"title":"Nonce"},"ciphertext":{"type":"string","maxLength":300000,"title":"Ciphertext"},"state":{"type":"string","pattern":"^[A-Za-z]{2}$","title":"State"},"sources":{"items":{"$ref":"#/components/schemas/Source"},"type":"array","minItems":1,"uniqueItems":true,"title":"Sources","description":"Required on purpose. NF-e and CT-e share one queue per CNPJ with any other system that already queries it: enable them only after checking that."}},"type":"object","required":["kid","encrypted_key","nonce","ciphertext","state","sources"],"title":"NewCertificate","description":"PFX and password arrive only inside the envelope; see app/certificates/envelope.py."},"PublicKey":{"properties":{"kid":{"type":"string","title":"Kid"},"algorithm":{"type":"string","title":"Algorithm"},"public_key_pem":{"type":"string","title":"Public Key Pem"}},"type":"object","required":["kid","algorithm","public_key_pem"],"title":"PublicKey"},"RunOut":{"properties":{"id":{"type":"integer","title":"Id"},"cnpj":{"type":"string","title":"Cnpj"},"source":{"type":"string","title":"Source"},"status":{"type":"string","title":"Status"},"started_at":{"type":"string","format":"date-time","title":"Started At"},"finished_at":{"type":"string","format":"date-time","title":"Finished At"},"pages":{"type":"integer","title":"Pages"},"first_nsu":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"First Nsu"},"last_nsu":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Nsu"},"fetched":{"type":"integer","title":"Fetched"},"unreadable":{"type":"integer","title":"Unreadable"},"reason":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Reason"}},"type":"object","required":["id","cnpj","source","status","started_at","finished_at","pages","first_nsu","last_nsu","fetched","unreadable","reason"],"title":"RunOut"},"SearchRequest":{"properties":{"serial_numbers":{"items":{"type":"string"},"type":"array","maxItems":100,"minItems":1,"title":"Serial Numbers"},"doc_type":{"anyOf":[{"type":"string","pattern":"^(nfe|nfse|cte)$"},{"type":"null"}],"title":"Doc Type"},"status":{"anyOf":[{"type":"string","pattern":"^(summary|complete|cancelled|denied)$"},{"type":"null"}],"title":"Status"},"issued_from":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Issued From"},"issued_to":{"anyOf":[{"type":"string","format":"date"},{"type":"null"}],"title":"Issued To"},"limit_per_certificate":{"type":"integer","maximum":500.0,"minimum":1.0,"title":"Limit Per Certificate","default":100},"include_xml":{"type":"boolean","title":"Include Xml","default":false},"cursors":{"additionalProperties":{"type":"string"},"type":"object","title":"Cursors"}},"type":"object","required":["serial_numbers"],"title":"SearchRequest"},"SearchResponse":{"properties":{"results":{"additionalProperties":{"$ref":"#/components/schemas/CertificateGroupOut"},"type":"object","title":"Results"},"not_found":{"items":{"type":"string"},"type":"array","title":"Not Found"}},"type":"object","required":["results","not_found"],"title":"SearchResponse"},"Source":{"type":"string","enum":["nfe","nfse","cte"],"title":"Source"},"SourceStatus":{"properties":{"source":{"type":"string","title":"Source"},"enabled":{"type":"boolean","title":"Enabled"},"last_nsu":{"type":"string","title":"Last Nsu"},"next_run_at":{"type":"string","format":"date-time","title":"Next Run At"},"blocked_until":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Blocked Until"},"last_success_at":{"anyOf":[{"type":"string","format":"date-time"},{"type":"null"}],"title":"Last Success At"},"last_error":{"anyOf":[{"type":"string"},{"type":"null"}],"title":"Last Error"}},"type":"object","required":["source","enabled","last_nsu","next_run_at","blocked_until","last_success_at","last_error"],"title":"SourceStatus"},"SourcesUpdate":{"properties":{"sources":{"items":{"$ref":"#/components/schemas/Source"},"type":"array","uniqueItems":true,"title":"Sources"}},"type":"object","required":["sources"],"title":"SourcesUpdate"},"ValidationError":{"properties":{"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"type":"array","title":"Location"},"msg":{"type":"string","title":"Message"},"type":{"type":"string","title":"Error Type"},"input":{"title":"Input"},"ctx":{"type":"object","title":"Context"}},"type":"object","required":["loc","msg","type"],"title":"ValidationError"}},"securitySchemes":{"APIKeyHeader":{"type":"apiKey","description":"Product key from app.cli create-client","in":"header","name":"X-API-Key"}}}}