API Overview

Learn the fundamentals of the VasBox REST API, including request/response formats, pagination, and versioning.

The VasBox API is a RESTful API that uses standard HTTP methods and returns JSON responses. All API access is over HTTPS, and all data is sent and received as JSON.

Base URL

All API requests should be made to the following base URLs:

EnvironmentBase URL
Productionhttps://api.vasbox.co.zw/v1
Sandboxhttps://sandbox.api.vasbox.co.zw/v1
Use the sandbox environment for development and testing. No real transactions are created.

Request Format

All requests must include the following headers:

HeaderValueRequired
AuthorizationBearer YOUR_API_KEYYes
Content-Typeapplication/jsonFor POST/PATCH/PUT
Acceptapplication/jsonRecommended

Example Request

Bash
curl -X POST https://api.vasbox.co.zw/v1/invoices \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json" \
  -d '{
    "customer_id": "cust_123",
    "items": [...]
  }'

Response Format

All responses are returned in JSON format. Successful responses include the requested resource, while error responses include an error object with details.

Success Response

JSON
{
  "id": "inv_abc123",
  "object": "invoice",
  "status": "draft",
  "total": 1500.00,
  "created_at": "2024-01-15T10:30:00Z"
}

Error Response

JSON
{
  "error": {
    "code": "validation_error",
    "message": "The given data was invalid.",
    "details": {
      "customer_id": ["The customer_id field is required."],
      "items": ["The items field must have at least 1 item."]
    }
  }
}

HTTP Status Codes

CodeStatusDescription
200OKRequest succeeded
201CreatedResource created successfully
400Bad RequestInvalid request parameters
401UnauthorizedInvalid or missing API key
403ForbiddenInsufficient permissions
404Not FoundResource not found
422Unprocessable EntityValidation failed
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer error

Pagination

List endpoints return paginated results. Use the page and per_page query parameters to navigate through results.

ParameterDefaultDescription
page1Page number to retrieve
per_page20Items per page (max 100)

Paginated Response

JSON
{
  "data": [
    { "id": "inv_001", ... },
    { "id": "inv_002", ... }
  ],
  "meta": {
    "current_page": 1,
    "per_page": 20,
    "total": 150,
    "last_page": 8
  },
  "links": {
    "first": "https://api.vasbox.co.zw/v1/invoices?page=1",
    "last": "https://api.vasbox.co.zw/v1/invoices?page=8",
    "prev": null,
    "next": "https://api.vasbox.co.zw/v1/invoices?page=2"
  }
}

Versioning

The API is versioned via the URL path. The current version is v1. When we make breaking changes, we'll release a new version while maintaining support for previous versions.

We'll notify you via email at least 6 months before deprecating any API version.