Skip to content

Declarações

Endpoints para gerenciamento de declarações alfandegárias.

GET /declarations

Lista paginada de declarações.

Request

bash
GET /api/v1/declarations
Authorization: Bearer <token>

Query Parameters

ParâmetroTipoPadrãoDescrição
pageint1Número da página
sizeint20Itens por página
searchstring-Buscar por referência
risk_levelstring-Filtrar por nível (low/medium/high/critical)

Exemplo

bash
curl "https://api.gbfiscalai.srv1164291.hstgr.cloud/api/v1/declarations?page=1&size=10&risk_level=high" \
  -H "Authorization: Bearer <token>"

Response 200

json
{
  "items": [
    {
      "id": 1,
      "reference": "DEC-2026-00001",
      "hs_code": "8703.23",
      "description": "Toyota Hilux 2023",
      "origin_country": "JP",
      "declared_value": 45000.00,
      "declared_weight": 2100.00,
      "quantity": 1,
      "risk_score": 72.5,
      "risk_level": "high",
      "status": "pending",
      "importer_id": 1,
      "created_at": "2026-01-12T10:00:00Z"
    }
  ],
  "total": 150,
  "page": 1,
  "size": 10,
  "pages": 15
}

GET /declarations/

Detalhes de uma declaração específica.

Request

bash
GET /api/v1/declarations/{id}
Authorization: Bearer <token>

Path Parameters

ParâmetroTipoDescrição
idintID da declaração

Exemplo

bash
curl https://api.gbfiscalai.srv1164291.hstgr.cloud/api/v1/declarations/1 \
  -H "Authorization: Bearer <token>"

Response 200

json
{
  "id": 1,
  "reference": "DEC-2026-00001",
  "hs_code": "8703.23",
  "description": "Toyota Hilux 2023",
  "origin_country": "JP",
  "declared_value": 45000.00,
  "declared_weight": 2100.00,
  "quantity": 1,
  "risk_score": 72.5,
  "risk_level": "high",
  "status": "pending",
  "importer": {
    "id": 1,
    "name": "Import Auto GW",
    "tax_id": "GW-IMP-001"
  },
  "alerts": [
    {
      "id": 5,
      "title": "Sous-évaluation détectée",
      "severity": "high"
    }
  ],
  "created_at": "2026-01-12T10:00:00Z",
  "updated_at": "2026-01-12T10:00:00Z"
}

Response 404

json
{
  "detail": "Declaration not found"
}

POST /declarations

Cria uma nova declaração.

Request

bash
POST /api/v1/declarations
Authorization: Bearer <token>
Content-Type: application/json

Body

json
{
  "reference": "DEC-2026-00100",
  "hs_code": "8703.23",
  "description": "Toyota Hilux 2023",
  "origin_country": "JP",
  "declared_value": 45000.00,
  "declared_weight": 2100.00,
  "quantity": 1,
  "importer_tax_id": "GW-IMP-001"
}

Campos

CampoTipoObrigatórioDescrição
referencestringSimReferência única
hs_codestringSimCódigo SH
descriptionstringSimDescrição da mercadoria
origin_countrystringSimCódigo do país ISO
declared_valuenumberSimValor em USD
declared_weightnumberNãoPeso em kg
quantityintNãoQuantidade
importer_tax_idstringNãoNIF do importador

Response 201

json
{
  "id": 100,
  "reference": "DEC-2026-00100",
  "risk_score": 65.0,
  "risk_level": "high",
  "status": "pending",
  "created_at": "2026-01-12T12:00:00Z"
}

Response 422

json
{
  "detail": [
    {
      "loc": ["body", "hs_code"],
      "msg": "field required",
      "type": "value_error.missing"
    }
  ]
}

Esquema Declaration

typescript
interface Declaration {
  id: number;
  reference: string;
  hs_code: string;
  description: string;
  origin_country: string;
  declared_value: number;
  declared_weight?: number;
  quantity?: number;
  risk_score: number;
  risk_level: 'low' | 'medium' | 'high' | 'critical';
  status: 'pending' | 'processing' | 'cleared' | 'flagged' | 'rejected';
  importer_id?: number;
  created_at: string;
  updated_at: string;
}

Ministerio das Financas - Guine-Bissau