How to manually test fiscal entity flows using curl.
POST /sessions)https://api.qa.contabeleza.com.br (QA) or https://api.dev.contabeleza.com.br (Dev)Every request requires these headers:
Authorization: Bearer <jwt_token>
ilm-business: <business_id>
Content-Type: application/vnd.api+json
Accept: application/json, application/vnd.api+json
export BASE="https://api.qa.contabeleza.com.br"
export TOKEN="eyJhbG..."
export BID="5"
export FEID="1" # fiscal entity ID
curl for debugging or when you need finer control.
Tests the full lifecycle of pass-invoices authentication and digital certificate management for a fiscal entity.
POST /fiscal-entities/{id}/pass-invoices
{
"data": {
"type": "fiscal-entity-pass-invoices",
"attributes": {
"password": "test-pass-only",
"authentication_type": "pass_only"
}
}
}
Expect 201. Extract data.id for later steps.
PATCH /fiscal-entities/{id}/pass-invoices/validate
Expect 200 with validation_status: "validating". Validation is async — the system checks credentials against eNotas in the background.
GET /fiscal-entities/{id}/pass-invoices
Expect 200. Verify authentication_type and status: "active".
Test switching between all three types:
| Type | Attributes |
|---|---|
token | password (the API token) |
user_and_pass | password + username |
pass_only | password (certificate password) |
PATCH /fiscal-entities/{id}/pass-invoices
{
"data": {
"type": "fiscal-entity-pass-invoices",
"attributes": {
"authentication_type": "token",
"password": "my-api-token-123"
}
}
}
PATCH /fiscal-entities/{id}/pass-invoices
{
"data": {
"type": "fiscal-entity-pass-invoices",
"attributes": { "password": "" }
}
}
Expect 200 with status: "inactive".
PATCH /fiscal-entities/{id}/pass-invoices
{
"data": {
"type": "fiscal-entity-pass-invoices",
"attributes": {
"password": "reactivated-password",
"authentication_type": "pass_only"
}
}
}
Expect 200 with status: "active".
multipart/form-data. The automated test runner skips these steps. For manual testing, you need a valid PFX file on disk.
GET /fiscal-entities/{id}/certificate
Expect 200 with data: null if no certificate exists.
POST /fiscal-entities/{id}/certificate
Content-Type: multipart/form-data
password: cert123456
data: <binary PFX file>
Expect 201. The certificate is stored encrypted and associated with the fiscal entity.
PATCH /fiscal-entities/{id}/certificate/validate
Expect 200 with validation_status: "validating". The system checks the certificate expiry, chain, and CNPJ match asynchronously.
GET /fiscal-entities/{id}/certificate
Expect 200. After validation completes, status should be "active".
DELETE /fiscal-entities/{id}/certificate
Expect 200 with status: "inactive". The certificate is soft-deleted.
GET /fiscal-entities/{id}/certificate
Expect 200 with data: null.
| Scenario | Request | Expected |
|---|---|---|
| Invalid entity ID (non-numeric) | GET /fiscal-entities/abc/pass-invoices |
400 Bad Request |
| Invalid entity ID for certificate | GET /fiscal-entities/abc/certificate |
400 Bad Request |
| Delete certificate for non-existent entity | DELETE /fiscal-entities/999999/certificate |
404 Not Found |
curl -s -X POST "$BASE/fiscal-entities/$FEID/pass-invoices" \
-H "Authorization: Bearer $TOKEN" \
-H "ilm-business: $BID" \
-H "Content-Type: application/vnd.api+json" \
-d '{
"data": {
"type": "fiscal-entity-pass-invoices",
"attributes": {
"password": "test-pass-only",
"authentication_type": "pass_only"
}
}
}' | jq .
curl -s -X PATCH "$BASE/fiscal-entities/$FEID/pass-invoices/validate" \
-H "Authorization: Bearer $TOKEN" \
-H "ilm-business: $BID" | jq .
Validates invoice emission setup for a fiscal entity. This flow requires credentials to exist first (run the Credentials flow or ensure pass-invoices/certificate are configured).
GET /fiscal-entities/{id}/pass-invoices
Expect 200. If 404, you need to create credentials first (see Credentials tab).
POST /fiscal-entities/{id}/invoices-emission
Expect 200 on success. May return 500 if INVOICES_READ_ONLY=true in the target environment.
This endpoint:
| Scenario | Request | Expected |
|---|---|---|
| Invalid entity ID | POST /fiscal-entities/abc/invoices-emission |
400 Bad Request |
| Non-existent entity | POST /fiscal-entities/999999/invoices-emission |
404 Not Found |
| No credentials configured | POST /fiscal-entities/{id}/invoices-emission |
Possible 500 or 422 depending on env |
curl -s -X POST "$BASE/fiscal-entities/$FEID/invoices-emission" \
-H "Authorization: Bearer $TOKEN" \
-H "ilm-business: $BID" | jq .
curl -s "$BASE/fiscal-entities/$FEID/pass-invoices" \
-H "Authorization: Bearer $TOKEN" \
-H "ilm-business: $BID" | jq '.data.attributes'