Core APIs (latest)

Introduction

The Rebilly API is built on HTTP and is RESTful. It has predictable resource URLs and returns HTTP response codes to indicate errors. It also accepts and returns JSON in the HTTP body. Use your favorite HTTP/REST library in your programming language when using this API, or use one of the Rebilly SDKs, which are available in PHP and JavaScript.

Every action in the Rebilly UI is supported by an API which is documented and available for use, so that you may automate any necessary workflows or processes. This API reference documentation contains the most commonly integrated resources.

Authentication

This topic describes the different forms of authentication that are available in the Rebilly API, and how to use them.

Rebilly offers four forms of authentication: secret key, publishable key, JSON Web Tokens, and public signature key.

  • Secret API key: Use to make requests from the server side. Never share these keys. Keep them guarded and secure.
  • Publishable API key: Use in your client-side code to tokenize payment information.
  • JWT: Use to make short-life tokens that expire after a set period of time.

Manage API keys

To create or manage API keys, select one of the following:

For more information on API keys, see API keys.

Errors

Rebilly follows the error response format proposed in RFC 9457, which is also known as Problem Details for HTTP APIs. As with any API responses, your client must be prepared to gracefully handle additional members of the response.

SDKs

Rebilly provides a JavaScript SDK and a PHP SDK to help interact with the Rebilly API. However, no SDK is required to use the API.

Rebilly also provides FramePay, a client-side iFrame-based solution, to help create payment tokens while minimizing PCI DSS compliance burdens and maximizing your customization ability. FramePay interacts with the payment tokens creation operation.

JavaScript SDK

For installation and usage instructions, see SDKs. All JavaScript SDK code examples are included in the API reference documentation.

PHP SDK

For installation and usage instructions, see SDKs. All SDK code examples are included in the API reference documentation. To use them, you must configure the $client as follows:

$client = new Rebilly\Client([
    'apiKey' => 'YourApiKeyHere',
    'baseUrl' => 'https://api.rebilly.com',
]);

Get started

The full Rebilly API has over 500 operations. This is likely more than you may need to implement your use cases. If you would like to implement a particular use case, contact Rebilly for guidance and feedback on the best API operations to use for the task.

To integrate Rebilly, and learn about related resources and concepts, see Get started.

Rate limits

Rebilly enforces rate limits on the API to ensure that no single organization consumes too many resources. Rate limits are applied to the organization, and not to the API key. In sandbox environment, rate limits are enforced for non-GET endpoints and are set at 3000 requests per 10 minutes. You can find the exact number of consumed requests in the X-RateLimit-Limit and X-RateLimit-Remaining headers in the response. If the rate limit is exceeded, the API returns a 429 Too Many Requests response and a X-RateLimit-Retry-After header that includes a UTC timestamp of when the rate limit resets.

Download OpenAPI description
Languages
Servers
Mock server
https://www.rebilly.com/_mock/docs/dev-docs/api/
Sandbox server
https://api-sandbox.rebilly.com/organizations/{organizationId}/
Live server
https://api.rebilly.com/organizations/{organizationId}/

Customers

Use these operations to manage customers. A customer is an entity that purchases goods or services from you (a merchant), and is the payee in any transaction that is credited to you. Customers are associated with payment instruments, subscriptions, invoices, and other related resources.

In other systems, customers may be referred to as accounts, clients, members, patrons, or players. For information on the customer resource, see Resources.

Operations

Customer authentication

Use these operations to validate the identity of users and manage authentication credentials.

Operations

Tags

Use tags to organize and categorize customers or KYC documents based on keywords.

Operations

Customers timeline

Use customer timelines to maintain an audit trail of changes and activity for each customer.

Operations

Payment instruments

Use these operations to manage payment instruments. Payment instrument is a term which describes any means of making a digital payment, such as: credit cards, debit cards, direct debits, payment service providers, and digital wallets.

For more information on payment instruments, see Payment instruments.

OperationsWebhooks

Payment tokens

Use payment tokens to reduce the scope of PCI DSS compliance.

A payment token can be made using a different authentication scheme (public key authentication), which enables you to create a payment token directly from the browser. This bypasses the need to send sensitive cardholder info to your servers. We recommend using this with the FramePay library, which helps you integrate a form into this API resource and create payment tokens.

Operations

Transactions

Use these operations to:

  • set up payment instruments for payments
  • authorize and hold funds
  • capture funds
  • make payments
  • make payouts
  • refund transactions.
Operations

Disputes

Use these operations to manage disputes. A dispute occurs when a customer contests a charge to their account. The dispute and related information is made available to the merchant by the bank or credit card company. The merchant then has the option to represent the charge and win the case. This process is called dispute resolution. If the merchant is unable to represent the charge, the card issuer typically reverses the sale and adds fees on top of the charge. This process is called a chargeback.

OperationsWebhooks

Fees

Use fees to reconcile transactions with applicable fees and discount rates. Fees are not applied directly to transaction amounts, they do not modify the transaction amount. Fees help to describe each part of the transaction amount.

Important: These operations are experimental and may change.

Operations

Transactions timeline

Use transaction timelines to maintain an audit trail of changes and activity for each transaction.

Operations

Orders

Use these operations to manage customer orders. An order is a customer's request to purchase items. It can contain subscription and one-time sale items. When an order contains one or more subscription items, it is a subscription order.

An order generates an invoice. A subscription order generates an invoice for each service period. For more information, see Orders.

Operations

Invoices

Use invoices to bill for the goods or services that you provide. If your invoice includes subscription items, it also includes the corresponding service periods and prices.

Operations

Usage

Use these operations to manage the product usage of a subscription item for metered billing purposes.

Use metered billing when product quantity is unknown to the customer at the moment of creating a subscription. Metered billing is based on reported usage records. Every reported usage updates the quantity of an upcoming invoice item for a specified subscription and a plan. To create a metered billing plan, see Plans.

Operations

Credit memos

Use credit memos to provide a customer with store credit. A common use case for using a credit memo is to provide a customer with store credit, rather than a refund, if the customer pays more than they owe or returns a product. For information on the credit memo resource, see Resources.

OperationsWebhooks

Plans

Use pricing plans to describe how the customer must pay for products.

Rebilly provides the following plan types:

  • Trial only: Use this plan to create and offer a free or discounted trial period for your product. For example, a free 2 week trial of an internet service. After the trial, the customer can choose to sign up for a paid subscription, or stop using the service.
  • Recurring: Use this plan to create and offer a subscription for your product. For example, a monthly subscription to an internet service that is charged at 20 USD per month.
  • One time sale: Use this plan to create and offer a one-off sale for your products. For example, a one time purchase of two bags of coffee.

For information on the plans resource, see Plans.

For information on plan pricing, see Pricing formulas.

Operations

Products

Use products to describe the goods and services that your business sells. A product also describes sales items on invoices and receipts. Product pricing is defined in plans. A product may have one or many plans.

For information on the product resource, see Product.

Operations

Coupons

Use coupons to reward customers, generate sales, or to test new pricing strategies. Coupons enable you to apply different types of discounts to invoices, subscriptions, and pricing plans.

Redeemed coupons are attached to a customer's account. Depending on the coupon restrictions, the redeemed coupons are then applied from the customer's account to subsequent invoices or subscriptions. Redeemed coupons can only be applied to invoices of the same currency.

Once a coupon is redeemed it cannot be modified. You may deactivate a coupon or create a new coupon, but you cannot reuse the same coupon code. If you have a use case where you must reuse the same code, contact Rebilly.

Operations

Coupon restriction types

The following coupon description types are available:

  • restrict-to-countries: Restricts a coupon for use in specific countries.
  • discounts-per-redemption: Restricts the number of times that the coupon can be applied by one redemption. For example, use this restriction to configure a coupon that can only be applied to the first subscription renewal of a particular product.
  • minimum-order-amount: Sets a minimum order amount for a coupon application. For example, if the restriction amount is $20, the coupon is only applied to invoices with a total amount of $20 or more.
  • restrict-to-invoices: Restricts a coupon to specific invoices.
  • restrict-to-plans: Restricts a coupon to specific pricing plans.
  • restrict-to-subscriptions: Restricts a coupon to specific order subscriptions.
  • restrict-to-customer-tags: Restricts a coupon to customers with specific tags.
  • restrict-to-customers: Restricts a coupon to specific customers.
  • restrict-to-exclusive-application: Restricts a coupon so that it cannot be used in combination with other coupons. If more than one coupon is active, a coupon with this restriction is only applied if it provides a larger discount than the other coupons combined. If a coupon with this restriction is applied, all other coupons are removed.
  • restrict-to-products: Restricts a coupon to specific products.
  • paid-by-time: Specifies a date and time at which a coupon redemption expires if not paid.
  • redemptions-per-customer: Restricts the number of times that a coupon can be redeemed by one customer. For example, use this restriction to limit the number of redemptions to one per customer.
  • total-redemptions: Restricts the number of times a coupon can be redeemed by different customers.
  • restrict-to-bxgy: Provides "buy X get Y" promotions. These promotions incentivize new customers to buy and also reward existing customers. This restriction type enables you to add discounted plans to an invoice when a certain quantity of other plans are purchased. For example, if a customer buys two or more books, they get one free bookmark.

Retrieve coupon redemptions

Request

Retrieves a list of coupon redemptions.

Query
limitinteger[ 0 .. 1000 ]

Limits the number of collection items to be returned.

offsetinteger[ 0 .. 1000 ]

Specifies the starting point within the collection of items to be returned.

filterstring

Filters the collection items. This field requires a special format. Use , for multiple allowed values. Use ; for multiple fields.

For more information, see Using filter with collections.

qstring

Use this field to perform a partial search of text fields.

sortArray of strings

Sorts and orders the collection of items. To sort in descending order, prefix with -. Multiple fields can be sorted by separating each with ,.

curl -i -X GET \
  'https://www.rebilly.com/_mock/docs/dev-docs/api/coupons-redemptions?filter=string&limit=1000&offset=1000&q=string&sort=string' \
  -H 'REB-APIKEY: YOUR_API_KEY_HERE'

Responses

List of coupon redemptions retrieved.

Headers
Pagination-Totalinteger

Total number of items.

Example: 332
Pagination-Limitinteger

Maximum number of items per page.

Example: 100
Pagination-Offsetinteger

Specifies the starting point within the collection of resource results. For example, a request with limit=20 retrieves and displays the first 20 results on a page. A following request with limit=20 and offset=20, retrieves the next page of 20 results.

Example: 2
Bodyapplication/jsonArray [
idstring<= 50 charactersread-only

Unique resource ID.

Example: "cpn_rdm_01HXC82EEPW6YD3MPWJY7151VR"
couponIdstring<= 50 characters

ID of the coupon.

Example: "cpn_0YVCNKF81GD778N4YNVGDJK558"
customerIdstring(CustomerId)<= 50 characters

ID of the customer resource.

additionalRestrictionsArray of objects(RedemptionRestriction)

Additional coupon redemption restrictions.

createdTimestring(date-time)(CreatedTime)read-only

Date and time which is set automatically when the resource is created.

updatedTimestring(date-time)(UpdatedTime)read-only

Date and time which updates automatically when the resource is updated.

canceledTimestring or null(date-time)read-only

Date and time when the coupon is canceled.

_linksArray of objectsread-only

Related links.

]
Response
application/json
[ { "id": "cpn_rdm_01HXC82EEPW6YD3MPWJY7151VR", "couponId": "cpn_0YVCNKF81GD778N4YNVGDJK558", "customerId": "cus_0YV7DDSDD1C8DA64KHH2W33CPF", "additionalRestrictions": [ … ], "createdTime": "2019-08-24T14:15:22Z", "updatedTime": "2019-08-24T14:15:22Z", "canceledTime": "2019-08-24T14:15:22Z", "_links": [ … ] } ]

Redeem a coupon

Request

Redeems a coupon.

Bodyapplication/jsonrequired

Coupon resource.

couponIdstring<= 50 characters

ID of the coupon.

Example: "cpn_0YVCNKF81GD778N4YNVGDJK558"
customerIdstring(CustomerId)<= 50 characters

ID of the customer resource.

additionalRestrictionsArray of objects(RedemptionRestriction)

Additional coupon redemption restrictions.

curl -i -X POST \
  https://www.rebilly.com/_mock/docs/dev-docs/api/coupons-redemptions \
  -H 'Content-Type: application/json' \
  -H 'REB-APIKEY: YOUR_API_KEY_HERE' \
  -d '{
    "couponId": "cpn_0YVCNKF81GD778N4YNVGDJK558",
    "customerId": "cus_0YV7DDSDD1C8DA64KHH2W33CPF",
    "additionalRestrictions": [
      {
        "type": "discounts-per-redemption",
        "quantity": 0
      }
    ]
  }'

Responses

Coupon redeemed.

Headers
Locationstring(uri)

Location of the related resource.

Example: "https://api.rebilly.com/example"
X-RateLimit-Limitinteger

Total number of rate limit tokens for this request within a rate limit period. For more information, see Rate limits.

Example: 3600
X-RateLimit-Remaininginteger

Remaining number of rate limit tokens for this request within the rate limit period. For example, in the sandbox environment, rate limits for non-GET endpoints are set at 3000 requests per 10 minutes.

Example: 3600
Bodyapplication/json
idstring<= 50 charactersread-only

Unique resource ID.

Example: "cpn_rdm_01HXC82EEPW6YD3MPWJY7151VR"
couponIdstring<= 50 characters

ID of the coupon.

Example: "cpn_0YVCNKF81GD778N4YNVGDJK558"
customerIdstring(CustomerId)<= 50 characters

ID of the customer resource.

additionalRestrictionsArray of objects(RedemptionRestriction)

Additional coupon redemption restrictions.

createdTimestring(date-time)(CreatedTime)read-only

Date and time which is set automatically when the resource is created.

updatedTimestring(date-time)(UpdatedTime)read-only

Date and time which updates automatically when the resource is updated.

canceledTimestring or null(date-time)read-only

Date and time when the coupon is canceled.

_linksArray of objectsread-only

Related links.

Response
application/json
{ "id": "cpn_rdm_01HXC82EEPW6YD3MPWJY7151VR", "couponId": "cpn_0YVCNKF81GD778N4YNVGDJK558", "customerId": "cus_0YV7DDSDD1C8DA64KHH2W33CPF", "additionalRestrictions": [ { … } ], "createdTime": "2019-08-24T14:15:22Z", "updatedTime": "2019-08-24T14:15:22Z", "canceledTime": "2019-08-24T14:15:22Z", "_links": [ { … } ] }

Retrieve a coupon redemption

Request

Retrieves a coupon redemption with a specified ID.

Path
idstring<= 50 characters^[@~\-\.\w]+$required

ID of the resource.

curl -i -X GET \
  'https://www.rebilly.com/_mock/docs/dev-docs/api/coupons-redemptions/{id}' \
  -H 'REB-APIKEY: YOUR_API_KEY_HERE'

Responses

Coupon redemption retrieved.

Bodyapplication/json
idstring<= 50 charactersread-only

Unique resource ID.

Example: "cpn_rdm_01HXC82EEPW6YD3MPWJY7151VR"
couponIdstring<= 50 characters

ID of the coupon.

Example: "cpn_0YVCNKF81GD778N4YNVGDJK558"
customerIdstring(CustomerId)<= 50 characters

ID of the customer resource.

additionalRestrictionsArray of objects(RedemptionRestriction)

Additional coupon redemption restrictions.

createdTimestring(date-time)(CreatedTime)read-only

Date and time which is set automatically when the resource is created.

updatedTimestring(date-time)(UpdatedTime)read-only

Date and time which updates automatically when the resource is updated.

canceledTimestring or null(date-time)read-only

Date and time when the coupon is canceled.