Check Status by requestId

GET /v2/documentos/{requestId}

Checks the validation result of a document without resending the NIF or private key. The gateway uses the credentials cached at issuance time.

Additive route: This is a simplified way to check document status. POST /v2/documentos/status keeps working normally and should be used as a fallback whenever the cache has expired.


How it works

When you successfully issued a document via POST /v2/documentos/emitir, the gateway automatically stored the company credentials (NIF + private key) in an encrypted cache, associated with the returned requestIdAGT.

When you call this route, the gateway:

  1. Verifies that the requestId belongs to your API Key
  2. Retrieves the NIF from the requestId → NIF mapping
  3. Retrieves the encrypted private key of the company
  4. Queries AGT and returns the status

You therefore do not need to store the private key in your own system to check status — as long as the cache is still valid.


Request

Authentication

x-api-key: feak_...

or

Authorization: Bearer feak_...

Required scope: facturas:consultar or facturas:emitir or *

Path Parameters

FieldTypeRequiredDescription
requestIdstring✅ YesThe requestIdAGT returned by the emitir endpoint

Example

GET /v2/documentos/202600002471491

Response

Success (200 OK)

The response format is identical to POST /v2/documentos/status:

{
  "success": true,
  "requestId": "202600002471491",
  "resultCode": "0",
  "resultado": "All documents valid",
  "documentos": [
    {
      "numero": "FT FT3926S9043N/1",
      "status": "valido"
    }
  ]
}

Response Fields

FieldTypeDescription
successbooleantrue, query performed successfully
requestIdstringThe ID of the queried request
resultCodestringGlobal result code (see table below)
resultadostringHuman-readable description of resultCode (respects Accept-Language)
documentosarrayList of documents and their statuses

Note: The resultado field is translated according to the Accept-Language header (pt or en). Other fields (resultCode, status, codigo) are technical codes and are not translated.

resultCode Meaning

CodeMeaningWhat to do
0All documents valid ✅Document was accepted by AGT
1Valid and invalid documents ⚠️Check documentos[].status field
2No document valid ❌Correct errors and reissue
7Premature query ⏳Wait and repeat the request
8Processing in progress ⏳Wait and repeat the request
9Processing cancelled ❌Contact AGT support

Errors

HTTPcodeMessageCause
401UNAUTHORIZEDNot authorized.API Key was not sent
403FORBIDDENInsufficient scope.The key does not have query scope
404REQUEST_NOT_FOUNDRequest not found.The requestId does not belong to this API Key
428CREDENTIALS_REQUIREDCredentials missing or expired.Cache expired (72h) — use POST /v2/documentos/status
502AGT_ERRORError communicating with AGT.Failed to contact AGT

About the 428 error

Credentials are cached for 72 hours after issuance. If you check the status after that period, you will receive 428 CREDENTIALS_REQUIRED. In that case, resend the NIF and private key in POST /v2/documentos/status, which keeps working with no time limit (as long as the record exists at AGT).


Code Examples

TypeScript / Node.js

const API_KEY = "feak_...";
const GATEWAY_URL = "https://connect.factflexi.com";

async function checkStatus(requestId: string) {
  const response = await fetch(
    `${GATEWAY_URL}/v2/documentos/${requestId}`,
    { headers: { "x-api-key": API_KEY } }
  );

  const data = await response.json();

  if (!data.success) {
    if (data.code === "CREDENTIALS_REQUIRED") {
      // Cache expired — use POST /status with NIF + privateKey
      console.log("Cache expired, use POST /v2/documentos/status");
    }
    throw new Error(`${data.code}: ${data.error}`);
  }

  console.log(`Result: ${data.resultado} (code: ${data.resultCode})`);
  return data;
}

// Usage
const status = await checkStatus("202600002471491");

Python

import requests

API_KEY = "feak_..."
GATEWAY_URL = "https://connect.factflexi.com"

def check_status(request_id: str) -> dict:
    response = requests.get(
        f"{GATEWAY_URL}/v2/documentos/{request_id}",
        headers={"x-api-key": API_KEY},
    )
    data = response.json()

    if not data.get("success"):
        raise Exception(f"{data.get('code')}: {data.get('error')}")

    print(f"Result: {data['resultado']} (code: {data['resultCode']})")
    return data

status = check_status("202600002471491")

cURL

curl -s https://connect.factflexi.com/v2/documentos/202600002471491 
  -H "x-api-key: feak_..."

When to use this route vs POST /status

SituationRecommended route
You just issued a document (less than 72h ago)GET /v2/documentos/{requestId} — simpler
More than 72h have passedPOST /v2/documentos/status with NIF + private key
You want full control over the credentials sentPOST /v2/documentos/status
You don’t want to store the private key in your systemGET /v2/documentos/{requestId}

See also