Integrate to PayEx Billing Customer API
Changelog
| Version | Date | Description | Created by |
|---|---|---|---|
| 1.0 | 2025-05-20 | Created document | Anders Göthberg |
| 1.1 | API in production | Anders Göthberg |
Introduction
A link to the general step-by-step implementation guide for setting up a REST API integration with PayEx Ledger Invoice Service can be found here
The Billing Customer API is used to create and update billable charges for a company’s end customers, both at the customer level and for each individual subscription
Customer API

Route description
Each resource in the API corresponds to its own route. All routes are structured according to a specific standard, explained below
The below route is an example of a route towards resource3Id. To perform operations on this resource, the route must also include the identifiers of its parent resources.
lf-api.payex.com/billing/{subdomain}/v1/{ownerNo}/resource1/{resource1Id}/resource2/{resource2Id}/resource3/{resource3Id}
| Route segment | Description |
|---|---|
| subdomain | In this part of the API it will be "billing" |
| ownerNo | The ledger identifier/number at PayEx |
| resource1Id | Identifier of resource1 (customers) |
| resource2Id | identifier of resource2, subresource to resource1 (recurring products or subscriptions) |
| resource3Id | identifier of resource3, subresource to resource2 (recurring products) |
Routes that occurs in examples of this documentation will use the following identifiers
| Resource | Identifier |
|---|---|
| ownerNo | The ledger identifier/number at PayEx |
| customerNo | Customer number |
| subscriptionNo | Subscription number (identifier for subscription) |
| recurring-products | Recurring products on customer or subscription level |
1. Customers
Get customer
1.1 Get specific Customer
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
Content-Type: application/json
{
"customerNo": "15615616",
"recurringProducts": "/billing/customer/v1/xxx/customers/15615616/recurring-products",
"subscriptions": "/billing/customer/v1/xxx/customers/15615616/subscriptions",
"operations": [
{
"rel": "add-subscription",
"method": "POST",
"href": "/billing/customer/v1/xxx/customers/15615616/subscriptions"
},
{
"rel": "add-recurring-product",
"method": "POST",
"href": "/billing/customer/v1/xxx/customers/15615616/recurring-products"
}
]
}
1.2 Create Customer
Adds customer
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
Request object specification
| Property | Data type | Format | Required | Description |
|---|---|---|---|---|
| customerNo | string | MinLength: 1 MaxLength: 15 Regex pattern:"[a-zA-Z0-9äåöÄÅÖ&/_ -.]*" | Yes | Identifier for customer |
Content-Type: application/json
{
"customerNo": "15615616",
"recurringProducts": "/billing/customer/v1/xxx/customers/15615616/recurring-products",
"subscriptions": "/billing/customer/v1/xxx/customers/15615616/subscriptions",
"operations": [
{
"rel": "add-subscription",
"method": "POST",
"href": "/billing/customer/v1/xxx/customers/15615616/subscriptions"
},
{
"rel": "add-recurring-product",
"method": "POST",
"href": "/billing/customer/v1/xxx/customers/15615616/recurring-products"
}
],
"@id": "/billing/customer/v1/xxx/customers/15615616"
}
Response object specification
| Property | Data type | Format | Description |
|---|---|---|---|
| @id | string | Uri identifier of the current resource | |
| customerNo | string | Identifier for customer | |
| recurringProducts | dynamic | Uri for selected recurrent lines | |
| subscriptions | dynamic | Uri for selected subscriptios | |
| operations | array | List of operations for this resource. See the documentation for more information. hypermedia part of the response |
2. Recurring-products
Lists recurring products on customer level
2.1 Get list of Recurring-products
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
The resource is used to get a list of recurring products on customer level
Content-Type: application/json
{
"items": [
{
"recurringProductId": "4444",
"baseProductCode": "F01",
"deviantText": "Fakturaavgift",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"deviantPrice": "29.000",
"deviantInterval": "",
"invoicedToDate": "",
"operations": [
{
"rel": "partial-update-recurring-product",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/recurring-products/4444"
}
],
"@id": "/billing/customer/v1/xxx/customers/224455/recurring-products/4444"
},
{
"recurringProductId": "4455",
"baseProductCode": "P02",
"deviantText": "Halvförsäkring",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"deviantPrice": "",
"deviantInterval": "",
"invoicedToDate": "",
"operations": [
{
"rel": "partial-update-recurring-product",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/recurring-products/4455"
}
],
"@id": "/billing/customer/v1/xxx/customers/224455/recurring-products/4455"
}
],
"navigation": {
"@id": "/billing/customer/v1/xxx/customers/224455/recurring-products"
}
}
Get specific recurring product on customer level
2.2 Get specific Recurring-product
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
The resource is used to get a specific recurring product
Content-Type: application/json
{
"recurringProductId": "4444",
"baseProductCode": "F01",
"deviantText": "Fakturaavgift",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"deviantPrice": "29.000",
"deviantInterval": "",
"invoicedToDate": "",
"operations": [
{
"rel": "partial-update-recurring-product",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/recurring-products/4444"
}
]
}
2.3 Create Recurring-product
Add recurring product on customer level
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
Request object specification
| Property | Data type | Format | Required | Description |
|---|---|---|---|---|
| baseProductCode | string | MinLength: 1 MaxLength: 5 Regex pattern:"[a-zA-Z0-9]*" | Yes | Predefined product ín PayEx Billing system |
| deviantText | string | MinLength: 1 MaxLength: 30 Regex pattern:"[a-zA-Z0-9]*" | No | Product text, default text from base product |
| startDate | string | Type: ISO 8601 | Yes | Product start date |
| endDate | string | Type: ISO 8601 | No | Product end date |
| deviantPrice | string | Type: N(7),N(2-6) | No | The products price for 1 day |
| deviantInterval | string | Type: N(1) | No | Deviant Interval determines how often the invoice is sent. Default/empty = 1 |
The resource is used to add recurring products on customer level
Content-Type: application/json
{
"recurringProductId": "4444",
"operations": [
{
"rel": "partial-update-recurring-product",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/recurring-products/4444"
}
],
"@id": "/billing/customer/v1/xxx/customers/224455/recurring-products/4444"
}
Response object specification
| Property | Data type | Format | Description |
|---|---|---|---|
| @id | string | Uri identifier of the current resource | |
| recurringProductId | string | Unique identifier for specific recurrent product | |
| baseProductCode | string | Predefined product in PayEx Billing system | |
| deviantText | string | Product text, default from base product | |
| startDate | string | Product start date | |
| endDate | string | Product end date | |
| deviantPrice | string | The price of the product, if price is not specified the base product price is used | |
| deviantInterval | string | Selected invoicing interval | |
| invoicedToDate | string | Date of how long the product has been invoiced (Indicating the date until product has been billed) | |
| operations | array | List of operations for this resource. See the documentation for more information. hypermedia part of the response |
2.4 Update recurrent line
Some properties on the recurrent line on customer level can be updated through this API. Properties will only be updated if included in the request.
The following recurrent line properties is possible to update through a patch call
| Property |
|---|
| endDate |
Update recurrent line end date
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"endDate": "YYYY-MM-DD"
}
3. Subscriptions
Lists subscriptions on customer
3.1 Get list of Subscriptions
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
Content-Type: application/json
{
"items": [
{
"subscriptionId": "10101010",
"subscriptionNo": "MF1122334455",
"name": "Lätt lastbilsförsäkring, ABC123",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"invoiceSeparately": true,
"deviantCollectionProcess": "",
"defaultPaymentMethod": true,
"deviantDistributionMethod": "Email",
"recurringProducts": "/billing/customer/v1/xxx/customers/224455/subscriptions/10101010/recurring-products",
"operations": [
{
"rel": "partial-update-subscription",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/10101010"
},
{
"rel": "add-recurring-product",
"method": "POST",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/10101010/recurring-products"
}
],
"@id": "/billing/customer/v1/xxx/customers/224455/subscriptions/10101010"
},
{
"subscriptionId": "22101010",
"subscriptionNo": "CV9988774455",
"name": "Fritidshusförsäkring",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"invoiceSeparately": true,
"deviantCollectionProcess": "",
"defaultPaymentMethod": true,
"deviantDistributionMethod": "Email",
"recurringProducts": "/billing/customer/v1/xxx/customers/224455/subscriptions/22101010/recurring-products",
"operations": [
{
"rel": "partial-update-subscription",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/22101010"
},
{
"rel": "add-recurring-product",
"method": "POST",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/22101010/recurring-products"
}
],
"@id": "/billing/customer/v1/xxx/customers/224455/subscriptions/22101010"
}
],
"navigation": {
"@id": "/billing/customer/v1/xxx/customers/224455/subscriptions"
}
}
Gets specific subscription
3.2 Get specific Subscription
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
Content-Type: application/json
{
"subscriptionId": "10101010",
"subscriptionNo": "MF1122334455",
"name": "Lätt lastbilsförsäkring, ABC123",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"invoiceSeparately": true,
"deviantCollectionProcess": "",
"defaultPaymentMethod": true,
"deviantDistributionMethod": "Email",
"recurringProducts": "/billing/customer/v1/xxx/customers/224455/subscriptions/10101010/recurring-products",
"operations": [
{
"rel": "partial-update-subscription",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/10101010"
},
{
"rel": "add-recurring-product",
"method": "POST",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/10101010/recurring-products"
}
]
}
3.3 Create Subscription
Adds subscription
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
Request object specification
| Property | Data type | Format | Required | Description |
|---|---|---|---|---|
| subscriptionNo | string | MinLength: 1 MaxLength: 34 Regex pattern:"[a-zA-Z0-9]*" | Yes | Identifier for subscription |
| name | string | MinLength: 1 MaxLength: 100 Regex pattern:"[a-zA-Z0-9]*" | Yes | Subscription text for presentation |
| startDate | string | Type: ISO 8601 | Yes | Subscription start date |
| endDate | string | Type: ISO 8601 | No | Subscription end date |
| invoiceSeparately | boolean | No | Default False=Invoicing on customer level True=Separate subscription number Invoice | |
| deviantCollectionProcess | string | No | If used, must be configured with PayEx | |
| defaultPaymentMethod | boolean | No | If True = default payment method in AR, overriding for example "customer direct debit consent" | |
| deviantDistributionMethod | string | No | "Postal", "Email", overrides customer default/preferred value |
Content-Type: application/json
{
"subscriptionId": "4444",
"recurringProducts": "/billing/customer/v1/xxx/customers/224455/subscriptions/4444/recurring-products",
"operations": [
{
"rel": "partial-update-subscription",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/4444"
},
{
"rel": "add-recurring-product",
"method": "POST",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/4444/recurring-products"
}
],
"@id": "/billing/customer/v1/xxx/customers/224455/subscriptions/4444"
}
Response object specification
| Property | Data type | Format | Description |
|---|---|---|---|
| @id | string | Uri identifier of the current resource | |
| subscriptionId | string | Identifier for subscription | |
| subscriptionNo | string | Unique identifier for specific subscription | |
| name | string | Subscription text for presentation | |
| startDate | string | Subscription start date | |
| endDate | string | Subscription end date | |
| invoiceSeparately | boolean | Default False=Invoicing on customer level True=Separate subscription number Invoicen | |
| deviantCollectionProcess | string | Selected collection process | |
| defaultPaymentMethod | boolean | Selected payment method | |
| deviantDistributionMethod | string | Selected distributions method | |
| recurringProducts | dynamic | Uri for selected subscriptions recurrent lines | |
| operations | array | List of operations for this resource. See the documentation for more information. hypermedia part of the response |
3.4 Update subscription
Some properties on the subscription can be updated through this API. Properties will only be updated if included in the request.
The following subscription properties is possible to update through a patch call
| Property |
|---|
| endDate |
| invoiceSeparately |
| deviantCollectionProcess |
| defaultPaymentMethod |
| deviantDistributionMethod |
Update subscription
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"endDate": "YYYY-MM-DD",
"invoiceSeparately": "True/False",
"deviantCollectionProcess": "Predefined value",
"defaultPaymentMethod": "True/False",
"deviantDistributionMethod": "Postal/Email"
}
4. Recurring-products
Lists subscription recurring products
4.1 Get list of Recurring-products
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
The resource is used to get a list of subscription recurring products
Content-Type: application/json
{
"items": [
{
"recurringProductId": "5544",
"baseProductCode": "F01",
"deviantText": "Fakturaavgift",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"deviantPrice": "29.000",
"deviantInterval": "",
"invoicedToDate": "",
"operations": [
{
"rel": "partial-update-recurring-product",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/2010101010/recurring-products/5544"
}
],
"@id": "/billing/customer/v1/xxx/customers/224455/subscriptions/2010101010/recurring-products/5544"
},
{
"recurringProductId": "5555",
"baseProductCode": "P02",
"deviantText": "Halvforsakring",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"deviantPrice": "",
"deviantInterval": "",
"invoicedToDate": "",
"operations": [
{
"rel": "partial-update-recurring-product",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/2010101010/recurring-products/5555"
}
],
"@id": "/billing/customer/v1/xxx/customers/224455/subscriptions/2010101010/recurring-products/5555"
}
],
"navigation": {
"@id": "/billing/customer/v1/xxx/customers/224455/subscriptions/2010101010/recurring-products"
}
}
Gets specific subscription recurring product
4.2 Get specific Recurring-product
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
The resource is used to get a specific subscription recurring product
Content-Type: application/json
{
"recurringProductId": "5544",
"baseProductCode": "F01",
"deviantText": "Fakturaavgift",
"startDate": "YYYY-MM-DD",
"endDate": "YYYY-MM-DD",
"deviantPrice": "29.000",
"deviantInterval": "",
"invoicedToDate": "",
"operations": [
{
"rel": "partial-update-recurring-product",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/2010101010/recurring-products/5544"
}
]
}
4.3 Create Recurring-product
Adds subscription recurring product
Host: -
Authorization: Bearer<Token>
Content-Type: application/json
Request object specification
| Property | Data type | Format | Required | Description |
|---|---|---|---|---|
| baseProductCode | string | MinLength: 1 MaxLength: 5 Regex pattern:"[a-zA-Z0-9]*" | Yes | Predefined product in PayEx Billing system |
| deviantText | string | MinLength: 1 MaxLength: 30 Regex pattern:"[a-zA-Z0-9]*" | No | Product text, default text from base product |
| startDate | string | Type: ISO 8601 | Yes | Product start date |
| endDate | string | Type: ISO 8601 | No | Product end date |
| deviantPrice | string | Type: N(7),N(2-6) | No | The products price for 1 day |
| deviantInterval | string | Type: N(1) | No | Deviant Interval determines how often the invoice is sent. Default = 1 |
The resource is used to add a subscription recurring product
Content-Type: application/json
{
"recurringProductId": "5544",
"operations": [
{
"rel": "partial-update-recurring-product",
"method": "PATCH",
"href": "/billing/customer/v1/xxx/customers/224455/subscriptions/2010101010/recurring-products/5544"
}
],
"@id": "/billing/customer/v1/xxx/customers/224455/subscriptions/2010101010/recurring-products/5544"
}
Response object specification
| Property | Data type | Format | Description |
|---|---|---|---|
| @id | string | Uri identifier of the current resource | |
| recurringProductId | string | Unique identifier for specific recurrent product | |
| baseProductCode | string | Predefined product in PayEx Billing system | |
| deviantText | string | Product text, default from base product | |
| startDate | string | Product start date | |
| endDate | string | Product end date | |
| deviantPrice | string | The price of the product, if price is not specified the base product price is used | |
| deviantInterval | string | Selected invoicing interval | |
| invoicedToDate | string | Date of how long the product has been invoiced (Indicating the date until product has been billed) | |
| operations | array | List of operations for this resource. See the documentation for more information. hypermedia part of the response |
4.4 Update recurrent line
Some properties on the recurrent line can be updated through this API. Properties will only be updated if included in the request.
The following recurrent line properties is possible to update through a patch call
| Property |
|---|
| endDate |
Update recurrent line end date
Host: -
Authorization: Bearer <Token>
Content-Type: application/json
{
"endDate": "YYYY-MM-DD"
}
Problems
All errors from the api are returned in the form of "problems" (response body), except for the http status code itself.
The problem object contain more detailed info on what the error is. The "type" property can be used to programmatically interpret the error as it contains a code definition of the problem.
Other properties can be useful for logging and subsequent troubleshooting. Some problems are extended with additional parameters so it may be a good idea to log response body as raw data to include these.
Problems of type validation does contain an additional list ("Problems") that describes exactly which parameter that failed the validation
Example
Content-Type: application/problem+json
{
"Type" : "ledger/{domain}/v1/problems/validation",
"Title" : "A validation error occurred",
"Status" : 400,
"Instance" : "215d4206-ca35-4f43-85ad-169c8f6d4ec1",
"Detail" : "A validation error occurred. Please fix the problems mentioned in the 'problems' property below.",
"Problems" :
{
"amount" : [
"Expected value between [0,01]-[79228162514264337593543950335] actual [0]"
]
}
}
Problem types
| Problem type (code) | Http status | Description |
|---|---|---|
| validation | 400 | occurs if any of the inputvalidation fails, it is described in the problem which parameter that failed the validation |
| customer-not-found | 404 | Customer not found in PayEx Billing |
| subscription-not-found | 404 | Subscription not found on selected customer |