Download OpenAPI specification:
API for creating sales orders from Versuni system
Welcome to the Sales Order API. This API enables Versuni system to create sales orders in our database through secure API requests.
The Sales Order API is designed to handle sales order creation and management with robust authentication and security measures.
This API serves as a bridge between the Versuni system and our database, allowing secure creation and management of sales orders. The system validates partner credentials and ensures data integrity through JWT authentication and RSA signature verification.
To start using this API:
client_id and client_secret/api/v1/auth/login endpoint to obtain a JWT tokenThe Versuni Sales Order API uses a two-layer authentication system to ensure secure communication:
Before making any API requests, you must obtain a JWT token by calling the /api/v1/auth/login endpoint with your client_id and client_secret.
Request Example:
POST /api/v1/auth/login
Content-Type: application/json
{
"client_id": "your-client-id",
"client_secret": "your-client-secret"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expired_at": 1704067200
}
The JWT token will be valid for 12 hours. After expiration, you can refresh it using the /api/v1/auth/refresh endpoint.
For creating sales orders, you must include an X-SIGNATURE header in addition to the JWT token. This signature ensures the request authenticity.
X-SIGNATURE = SHA256withRSA(PrivateKey, StringToSign)
StringToSign = client_id + "|" + X-TIMESTAMP
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAomV+Vm1xlRXanmh108Ku
sls7SSKec0oCejtc9QGObpd4RnQ+7gihm2k6etnSNP7b+XrpY+fBkiQNaBInii9M
10kW9Bhf/M9GH/edL3IqnzDNSi7tcoQgnO7h8xmzLNWHTjtR6bkrsdBS5dry6hto
taF5KXomuoYgztCdGDOa0W20aeLzYSXIoW7s/Ay5yIXt0xaXTll3/bmezleguFPn
wQZq5EqZFWlUZvutDi+f2l9rTRY0Fb64y+VAf+mnIbEovGqsPEeF/p97YWxcY7CW
m8NsT0lwBVOtkmEl967Brz5yvEObF5bJgVodi6mNVsN1ki0MCitIhYO8shcE7eUi
lQIDAQAB
-----END PUBLIC KEY-----
When creating a sales order, include the following headers:
Required Headers:
Authorization: Bearer <JWT_TOKEN>
X-CLIENT-ID: <your-client-id>
X-TIMESTAMP: <current-unix-timestamp>
X-SIGNATURE: <generated-signature>
Content-Type: application/json
client_id from the JWT token must match the X-CLIENT-ID headerX-SIGNATURE will be verified using your registered public keyX-TIMESTAMP should be the current timestamp used in signature generationIf your JWT token expires, you can refresh it without re-authenticating:
Request Example:
POST /api/v1/auth/refresh
Content-Type: application/json
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"expired_at": 1704110400
}
client_secret or private key| client_id required | string Client ID |
| client_secret required | string Client Secret |
{- "client_id": "versuni-client-001",
- "client_secret": "secret-key-123"
}{- "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
- "expired_at": 1704067200
}| token required | string JWT Token |
{- "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}{- "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
- "expired_at": 1704067200
}| customer_code required | string Customer code |
| site_code required | string Site code |
| sales_name required | string Sales person name |
| address required | string Delivery address |
required | Array of objects (ProductDto) List of products |
{- "customer_code": "CUST-001",
- "site_code": "SITE-001",
- "sales_name": "John Doe",
- "address": "Jl. Sudirman No. 1, Jakarta",
- "products": [
- {
- "product_code": "PROD-001",
- "quantity": 10
}
]
}{- "message": "Sales order created successfully",
- "data": {
- "code": "SO-20250101-00001",
- "status": "DRAFT",
- "created_at": "2025-01-01T00:00:00.000Z"
}
}