Cargo Poster API Documentation

Welcome to the Cargo Poster API documentation. Our API provides programmatic access to manage cargo shipments, passports, and track deliveries efficiently.

Base URL

https://cargoposter.com

Authentication Required

Most endpoints require authentication using Bearer tokens. Make sure to include your token in the Authorization header.

Authentication

Login & Get Token

Authenticate a user and receive an access token for API requests.

POST /api/auth/login

Request Body:

{
  "email": "user@example.com",
  "password": "your_password"
}

Response:

{
  "user": {
    "id": 1,
    "email": "user@example.com",
    "name": "John Doe"
  },
  "token": "your_access_token_here"
}

Cargo Management

Get Cargo List

Retrieve a list of all cargo shipments for the authenticated user.

GET /api/cargos

Headers:

Authorization: Bearer your_access_token_here
Content-Type: application/json

Response:

{
  "data": [
    {
      "id": 1,
      "title": "Electronics Shipment",
      "weight": 1500,
      "volume": 2.5,
      "pickup_location": "Vilnius, Lithuania",
      "delivery_location": "Berlin, Germany",
      "status": "pending",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "total": 10,
    "per_page": 15
  }
}

Get Single Cargo

Retrieve details of a specific cargo shipment by ID.

GET /api/cargos/{id}

Headers:

Authorization: Bearer your_access_token_here
Content-Type: application/json

URL Parameters:

id (integer, required): The ID of the cargo to retrieve

Response:

{
  "data": {
    "id": 1,
    "title": "Electronics Shipment",
    "description": "Laptops and mobile phones",
    "weight": 1500,
    "volume": 2.5,
    "pickup_location": "Vilnius, Lithuania",
    "pickup_date": "2024-02-01",
    "delivery_location": "Berlin, Germany",
    "delivery_date": "2024-02-03",
    "status": "pending",
    "cargo_type": {
      "id": 1,
      "name": "Electronics"
    },
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}

Create Cargo

Create a new cargo shipment.

POST /api/cargos

Headers:

Authorization: Bearer your_access_token_here
Content-Type: application/json

Request Body:

{
  "title": "Electronics Shipment",
  "description": "Laptops and mobile phones",
  "weight": 1500,
  "volume": 2.5,
  "pickup_location": "Vilnius, Lithuania",
  "pickup_date": "2024-02-01",
  "delivery_location": "Berlin, Germany",
  "delivery_date": "2024-02-03",
  "cargo_type_id": 1
}

Response:

{
  "data": {
    "id": 1,
    "title": "Electronics Shipment",
    "description": "Laptops and mobile phones",
    "weight": 1500,
    "volume": 2.5,
    "pickup_location": "Vilnius, Lithuania",
    "delivery_location": "Berlin, Germany",
    "status": "pending",
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Update Cargo

Update an existing cargo shipment by its ID.

PUT /api/cargos/{id}

Headers:

Authorization: Bearer your_access_token_here
Content-Type: application/json

URL Parameters:

id (required): The unique identifier of the cargo to update

Request Body:

{
  "title": "Updated Electronics Shipment",
  "description": "Updated laptops and mobile phones",
  "weight": 1600,
  "volume": 2.8,
  "pickup_location": "Vilnius, Lithuania",
  "pickup_date": "2024-02-02",
  "delivery_location": "Hamburg, Germany",
  "delivery_date": "2024-02-05",
  "cargo_type_id": 1
}

Response:

{
  "data": {
    "id": 1,
    "title": "Updated Electronics Shipment",
    "description": "Updated laptops and mobile phones",
    "weight": 1600,
    "volume": 2.8,
    "pickup_location": "Vilnius, Lithuania",
    "delivery_location": "Hamburg, Germany",
    "status": "pending",
    "updated_at": "2024-01-15T11:45:00Z"
  }
}

Error Responses:

404 Not Found:
{
  "message": "Cargo not found"
}

422 Validation Error:
{
  "message": "The given data was invalid.",
  "errors": {
    "title": ["The title field is required."],
    "weight": ["The weight must be a positive number."]
  }
}

Passport Management

Get Passport List

Retrieve a list of all passports for cargo tracking.

GET /api/passports

Headers:

Authorization: Bearer your_access_token_here
Content-Type: application/json

Response:

{
  "data": [
    {
      "id": 1,
      "passport_number": "PS001234",
      "cargo_id": 1,
      "status": "active",
      "issued_date": "2024-01-15",
      "expiry_date": "2024-12-31",
      "created_at": "2024-01-15T10:30:00Z"
    }
  ],
  "meta": {
    "current_page": 1,
    "total": 5,
    "per_page": 15
  }
}

Get Single Passport

Retrieve details of a specific passport by ID.

GET /api/passports/{id}

Headers:

Authorization: Bearer your_access_token_here
Content-Type: application/json

URL Parameters:

id (integer, required): The ID of the passport to retrieve

Response:

{
  "data": {
    "id": 1,
    "passport_number": "PS001234",
    "cargo_id": 1,
    "status": "active",
    "issued_date": "2024-01-15",
    "expiry_date": "2024-12-31",
    "notes": "Special handling required",
    "cargo": {
      "id": 1,
      "title": "Electronics Shipment",
      "weight": 1500,
      "volume": 2.5
    },
    "created_at": "2024-01-15T10:30:00Z",
    "updated_at": "2024-01-15T10:30:00Z"
  }
}

Create Passport

Create a new passport for cargo tracking.

POST /api/passports

Headers:

Authorization: Bearer your_access_token_here
Content-Type: application/json

Request Body:

{
  "cargo_id": 1,
  "passport_number": "PS001234",
  "issued_date": "2024-01-15",
  "expiry_date": "2024-12-31",
  "notes": "Special handling required"
}

Response:

{
  "data": {
    "id": 1,
    "passport_number": "PS001234",
    "cargo_id": 1,
    "status": "active",
    "issued_date": "2024-01-15",
    "expiry_date": "2024-12-31",
    "notes": "Special handling required",
    "created_at": "2024-01-15T10:30:00Z"
  }
}

Error Codes

The API uses conventional HTTP response codes to indicate success or failure of requests.

Status Code Meaning Description
200 OK Request successful
201 Created Resource created successfully
400 Bad Request Invalid request parameters
401 Unauthorized Authentication required
403 Forbidden Access denied
404 Not Found Resource not found
422 Unprocessable Entity Validation error
500 Internal Server Error Server error

Rate Limits

The API implements rate limiting to ensure fair usage. Each authenticated user is limited to:

  • 1000 requests per hour for standard endpoints
  • 100 requests per hour for data-intensive endpoints
  • Rate limit headers are included in all responses

Support

If you have questions about using the API or encounter any issues, please don't hesitate to reach out:

We connect shippers and carries for seamless cargo orders experience.

Post your cargo & get it delivered!

Refer to colleague

Are you colleagues struggling finding ways how to manage cargos? Let them know about Cargo Poster.

© 2024 Cargo Poster (all) IP: 216.73.216.117 Location: US Columbus