Create a payment rule
How to create a payment rule via API
To create a new payment rule, send a POST request to the /api/2026-05/payment_rules endpoint, passing the resource arguments in the request body.
Request
POST https://yourdomain.commercelayer.io/api/2026-05/payment_rules
Arguments
type
string
Required
attributes.template_id
string
Required
attributes.template_settings
object
Required
attributes.expires_at
string
Optional
attributes._disable
boolean
Optional
attributes._enable
boolean
Optional
attributes.reference
string
Optional
attributes.reference_origin
string
Optional
attributes.metadata
object
Optional
relationships.ruleable
object
Required
Example
The following request creates a new payment rule:
curl -g -X POST \
'https://yourdomain.commercelayer.io/api/2026-05/payment_rules' \
-H 'Accept: application/vnd.api+json' \
-H 'Authorization: Bearer your-access-token' \
-H 'Content-Type: application/vnd.api+json' \
-d '{
"data": {
"type": "payment_rules",
"attributes": {
"template_id": "351af371-4090-43cf-af58-762244e19f9c",
"template_settings": {}
},
"relationships": {
"ruleable": {
"data": {
"type": "markets",
"id": "ABCRtyUpBa"
}
}
}
}
}'On success, the API responds with a 201 Created status code, returning the created resource object:
Last updated