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:

GET
/api/v1/company

Get current company information

PATCH
/api/v1/company/configurations

Update company configurations


Get Company Information

GET
/api/v1/company
Authorization: Bearer {YOUR_ACCESS_TOKEN}

This endpoint returns information of the current company and related configurations.

Required permissions:

  • Scope: company
  • User role: Admin or SuperAdmin
1
2
curl -X GET "https://my.sepay.vn/api/v1/company" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
RESPONSE
{
    "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
                }
            ]
        }
    }
}
idinteger

Company ID

full_namestring

Full company name

short_namestring

Short company name

rolestring

User's role in the company

statusstring

Company status (active, inactive, etc.)

subscriptionstring

Company subscription plan

begin_datestring

Subscription start date

end_datestring

Subscription end date

configurationsobject

Company configurations


Update Company Configurations

PATCH
/api/v1/company/configurations
Authorization: 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: Admin or SuperAdmin

Request parameters:

payment_code_formatsarrayrequired
List of payment code formats

payment_code_formats details:

ParameterTypeRequiredDescription
prefixstringYesPayment code prefix. Contains only letters, length 2–3 characters
suffix_fromintegerYesMinimum suffix length. Integer from 1–30
suffix_tointegerYesMaximum suffix length. Integer from 1–30, must be greater than or equal to suffix_from
character_typestringYesSuffix character type. Can only be NumberOnly or NumberAndLetter
is_activeintegerYesActive status of this format. Can only be 0 or 1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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:

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:

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:

401Unauthorized

Access token is invalid or expired

403Forbidden

Insufficient permissions (not Admin or SuperAdmin)

400Bad Request

Invalid data submitted (does not meet constraints)

500Internal Server Error

Server error while processing request