Skip to content

Import

Endpoints for importing declarations from CSV/Excel files.

POST /imports/csv

Imports declarations from a CSV file.

Request

bash
POST /api/v1/imports/csv
Authorization: Bearer <token>
Content-Type: multipart/form-data

Body

FieldTypeDescription
fileFileCSV file to import

Example with curl

bash
curl -X POST https://api.gbfiscalai.srv1164291.hstgr.cloud/api/v1/imports/csv \
  -H "Authorization: Bearer <token>" \
  -F "file=@declarations.csv"

Response 200

json
{
  "total_rows": 100,
  "imported": 95,
  "errors": 5,
  "high_risk_count": 12,
  "alerts_created": 8,
  "error_details": [
    {
      "row": 15,
      "error": "Missing required field: hs_code"
    },
    {
      "row": 42,
      "error": "Invalid country code: XYZ"
    }
  ]
}

POST /imports/excel

Imports declarations from an Excel file.

Request

bash
POST /api/v1/imports/excel
Authorization: Bearer <token>
Content-Type: multipart/form-data

Body

FieldTypeDescription
fileFileExcel file (.xlsx, .xls)

Example

bash
curl -X POST https://api.gbfiscalai.srv1164291.hstgr.cloud/api/v1/imports/excel \
  -H "Authorization: Bearer <token>" \
  -F "file=@declarations.xlsx"

Response 200

Same format as CSV import.

File Format

Required Columns

ColumnTypeExample
referencestringDEC-2026-00100
hs_codestring8703.23
descriptionstringToyota Hilux
origin_countrystringJP
declared_valuenumber45000

Optional Columns

ColumnTypeExample
importer_tax_idstringGW-IMP-001
declared_weightnumber2100
quantitynumber1

CSV Example

csv
reference,importer_tax_id,hs_code,description,origin_country,declared_value,declared_weight,quantity
DEC-2026-00100,GW-IMP-001,8703.23,Toyota Hilux 2023,JP,45000,2100,1
DEC-2026-00101,GW-IMP-002,8517.12,iPhone 15 Pro Max,CN,150,0.2,500
DEC-2026-00102,GW-IMP-003,2204.21,Vin rouge Bordeaux AOC,FR,8500,750,500

ISO Country Codes

Use ISO 3166-1 alpha-2 codes:

CodeCountry
GWGuinea-Bissau
CNChina
JPJapan
FRFrance
PTPortugal
USUnited States
DEGermany
SNSenegal

Limits

LimitValue
Max file size10 MB
Max rows10,000
Simultaneous imports1 per user

Error Handling

Validation Errors

json
{
  "error_details": [
    {
      "row": 5,
      "error": "Missing required field: reference"
    }
  ]
}

Common Error Codes

ErrorCause
Missing required fieldRequired field is missing
Invalid value typeData type is incorrect
Invalid country codeCountry code not recognized
Duplicate referenceReference already exists
Value out of rangeValue is out of limits

Import Process

1. File upload

2. Format validation

3. Line parsing

4. Data validation

5. Risk score calculation

6. Declaration creation

7. Alert generation (if risk > 75%)

8. Update importer scores

9. Return import report

ImportResult Schema

typescript
interface ImportResult {
  total_rows: number;
  imported: number;
  errors: number;
  high_risk_count: number;
  alerts_created: number;
  error_details: Array<{
    row: number;
    error: string;
  }>;
}

Ministry of Finance - Guinea-Bissau