Company API
Documentation on using the company API through OAuth2 in SePay.
Introduction
SePay's Company API allows you to access information about the current company and company configurations. This API is only available for users with Admin or SuperAdmin role in the company.
To use this API, you need the company permission in the Access Token scope and must be a user with Admin or SuperAdmin role.
Endpoints
The Company API provides the following endpoints:
/api/v1/companyGet current company information
/api/v1/company/configurationsUpdate company configurations
Get Company Information
/api/v1/companyAuthorization: Bearer {YOUR_ACCESS_TOKEN}
This endpoint returns information of the current company and related configurations.
Required permissions:
- Scope:
company - User role:
AdminorSuperAdmin
curl -X GET "https://my.sepay.vn/api/v1/company" \-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
{
"status": "success",
"data": {
"id": 123,
"full_name": "Công ty TNHH Một Thành Viên ABC",
"short_name": "ABC Corp",
"role": "Admin",
"status": "active",
"subscription": "Premium",
"begin_date": "2023-01-01",
"end_date": "2023-12-31",
"configurations": {
"bank_sub_account": true,
"paycode": true,
"data_storage_time": "90",
"payment_code_formats": [
{
"prefix": "DH",
"suffix_from": 6,
"suffix_to": 8,
"character_type": "NumberOnly",
"is_active": true
},
{
"prefix": "HD",
"suffix_from": 4,
"suffix_to": 6,
"character_type": "NumberAndLetter",
"is_active": true
}
]
}
}
}idintegerCompany ID
full_namestringFull company name
short_namestringShort company name
rolestringUser's role in the company
statusstringCompany status (active, inactive, etc.)
subscriptionstringCompany subscription plan
begin_datestringSubscription start date
end_datestringSubscription end date
configurationsobjectCompany configurations
Update Company Configurations
/api/v1/company/configurationsAuthorization: Bearer {YOUR_ACCESS_TOKEN}
Content-Type: application/json
This endpoint allows you to update company configurations, especially payment code formats.
Required permissions:
- Scope:
company - User role:
AdminorSuperAdmin
Request parameters:
payment_code_formats details:
| Parameter | Type | Required | Description |
|---|---|---|---|
prefix | string | Yes | Payment code prefix. Contains only letters, length 2–3 characters |
suffix_from | integer | Yes | Minimum suffix length. Integer from 1–30 |
suffix_to | integer | Yes | Maximum suffix length. Integer from 1–30, must be greater than or equal to suffix_from |
character_type | string | Yes | Suffix character type. Can only be NumberOnly or NumberAndLetter |
is_active | integer | Yes | Active status of this format. Can only be 0 or 1 |
curl -X PATCH "https://my.sepay.vn/api/v1/company/configurations" \-H "Content-Type: application/json" \-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \-d '{"payment_code_formats": [{"prefix": "DH","suffix_from": 6,"suffix_to": 8,"character_type": "NumberOnly","is_active": 1},{"prefix": "HD","suffix_from": 4,"suffix_to": 6,"character_type": "NumberAndLetter","is_active": 1}]}'
Success response:
{
"status": "success",
"data": {
"status": true,
"data": {
"bank_sub_account": true,
"paycode": true,
"data_storage_time": "90",
"payment_code_formats": [
{
"prefix": "DH",
"suffix_from": 6,
"suffix_to": 8,
"character_type": "NumberOnly",
"is_active": true
},
{
"prefix": "HD",
"suffix_from": 4,
"suffix_to": 6,
"character_type": "NumberAndLetter",
"is_active": true
}
]
}
}
}Error response:
{
"status": "success",
"data": {
"status": false,
"message": "Payment code suffix from must be less than or equal to suffix to (Payment code format 1)"
}
}Error Codes
Below are the error codes that may be encountered when using the Company API:
401UnauthorizedAccess token is invalid or expired
403ForbiddenInsufficient permissions (not Admin or SuperAdmin)
400Bad RequestInvalid data submitted (does not meet constraints)
500Internal Server ErrorServer error while processing request