API Overview
Getting started with the CostSync API
Last updated: 17th January 2025
API Overview
The CostSync API provides programmatic access to your cost and profit data.
Authentication
Getting Your API Key
- Go to Settings > API in CostSync
- Click Generate API Key
- Copy and securely store your key
⚠️
Warning
Keep your API key secure. Never expose it in client-side code or public repositories.
Using Your API Key
Include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Available Endpoints
Products
| Method | Endpoint | Description |
|---|---|---|
| GET | /products | List all products |
| GET | /products/:id | Get a single product |
| PUT | /products/:id/cost | Update product cost |
Orders
| Method | Endpoint | Description |
|---|---|---|
| GET | /orders | List orders with profit |
| GET | /orders/:id | Get order details |
Suppliers
| Method | Endpoint | Description |
|---|---|---|
| GET | /suppliers | List all suppliers |
| POST | /suppliers | Create a supplier |
| PUT | /suppliers/:id | Update a supplier |
Reports
| Method | Endpoint | Description |
|---|---|---|
| GET | /reports/profit | Get profit report |
| GET | /reports/products | Get product performance |
Response Format
All responses are JSON formatted:
{
"success": true,
"data": {
// Response data here
},
"meta": {
"page": 1,
"per_page": 50,
"total": 150
}
}
Error Handling
Errors return appropriate HTTP status codes:
| Code | Meaning |
|---|---|
| 400 | Bad request - check your parameters |
| 401 | Unauthorized - check your API key |
| 403 | Forbidden - insufficient permissions |
| 404 | Not found - resource doesn't exist |
| 429 | Rate limited - slow down requests |
| 500 | Server error - contact support |
Error response format:
{
"success": false,
"error": {
"code": "INVALID_PARAMETER",
"message": "The 'product_id' parameter is required"
}
}
Pagination
List endpoints support pagination:
GET /products?page=2&per_page=50
Need Help?
- Email: api@costsync.app
- Support Portal