API Reference

The Recharge API is primarily a REST API with some RPC endpoints to support common operations. It has predictable, resource-oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and methods.

Related guides: Generate API tokens, Using the API



API and Platforms compatibility

Recharge offers hosted solutions and integrates with various ecommerce platforms to process recurring transactions with the setup of your choice. In order to be compatible with those platforms some of our API resources and endpoints may be limited in use to a subset of platforms. When that is the case we will flag with the help of tags the checkout/platform association for which that feature is compatible.
When there is no restriction of compatibility no tags will appear.
Below is a legend of the tags you may come across:


Tag Checkout solution Ecommerce platform
BigCommerce Recharge hosted BigCommerce
Custom Recharge hosted or API-first Custom
RCS Recharge hosted Shopify
SCI Shopify hosted Shopify

You may also come across other tags specifying regional restrictions (e.g. USA Only) or new releases (e.g. Alpha, Beta).



Intro image
Base URL
https://api.rechargeapps.com

Authentication

Recharge uses API keys to authenticate requests.

Each request to the API should contain an API token in the following header:

X-Recharge-Access-Token:store_api_token

Replace store_api_token with your API key.

All requests must be made over HTTPS.


API Token Scopes

Scopes can be set up from the API token edit page in Recharge to control the level of access of an API token.

The API currently supports the scopes below:

Write Read
read_accounts
write_batches read_batches
write_charges read_charges
write_customers read_customers
write_discounts read_discounts
write_notifications
write_orders read_orders
write_payment_methods read_payment_methods
write_products read_products
write_subscriptions read_subscriptions
write_webhooks read_webhooks
read_store
GET /
curl -i -H 'X-Recharge-Access-Token: your_api_token'
-X GET

Versioning

All requests will use your account API settings, unless you send a X-Recharge-Version header to specify the version.
You can use the same token to make calls to all versions. When no version is specified it will default to the default version on your store.

Existing API Versions Release notes
2021-11 2021-11 release notes
2021-01

Responses

Recharge uses conventional HTTP response codes to indicate the success or failure of an API request. In general, codes in the 2xx range indicate success, codes in the 4xx range indicate an error that failed given the information provided ( e.g. a required parameter was omitted, a charge failed, etc ), and codes in the 5xx range indicate an error with Recharge’s servers.

200 - OK: Everything worked as expected.
201 - OK: The request was successful, created a new resource, and resource created is in the body.
202 - OK: The request has been accepted and is in processing.
204 - OK: The server has successfully fulfilled the request and there is no content to send in the response body.
400 - Bad Request: The request was unacceptable, often due to a missing required parameter.
401 - Unauthorized: No valid API key was provided.
402 - Request Failed: The parameters were valid but the request failed.
403 - The request was authenticated but not authorized for the requested resource (permission scope error).
404 - Not Found: The requested resource doesn’t exist.
405 - Method Not Allowed: The method is not allowed for this URI.
406 - The request was unacceptable, or requesting a data source which is not allowed although permissions permit the request.
409 - Conflict: You will get this error when you try to send two requests to edit an address or any of its child objects at the same time, in order to avoid out of date information being returned.
415 - The request body was not a JSON object.
422 - The request was understood but cannot be processed due to invalid or missing supplemental information.
426 - The request was made using an invalid API version.
429 - The request has been rate limited.
500 - Internal server error.
501 - The resource requested has not been implemented in the current version but may be implemented in the future.
503 - A 3rd party service on which the request depends has timed out.

Extending responses

Our API endpoints and webhooks allow developers to extend responses with additional data in order to optimize calls, allowing for simpler and more efficient implementations.

The API supports including additional objects when using a GET request to retrieve a list or a GET request to retrieve a record by a specific id. This is achieved by using an include query parameter in the request URL. The include value contains the object or objects you want to include in the response of your request. On routes where multiple includes are available, you are able to pass multiple values serparated by a comma ( include=customer,metafields ). The below table defines available include values for commonly used resources of the API.
Webhooks support included_objects on the topics listed below. Webhook included_objects accepts an array of supported values ( included_objects: [ "customer", "metafields"] ). Specifying included_objects will return an enriched payload, containing the original resource and the associated included objects.

Resource Endpoints Webhook topics Supported include and included_objects values
Addresses GET /addresses
GET /addresses/{id}
address/created
address/updated
customer
payment_methods(beta)
Charges GET /charges
GET /charges/{id}
charge/created
charge/failed
charge/max_retries_reached
charge/paid
charge/refunded
charge/uncaptured
charge/upcoming
charge/updated
charge/deleted
customer
metafields
payment_methods (beta)
Customers GET /customers
GET /customers/{id}
customer/activated
customer/created
customer/deactivated
customer/payment_method_updated
customer/updated
customer/deleted
addresses
metafields
payment_methods (beta)
Orders order/cancelled
order/created
order/deleted
order/processed
order/payment_captured
order/upcoming
order/updated
order/success
GET /orders
GET /orders/{id}
customer
metafields
Payment Methods GET /payment_methods
GET /payment_methods/{id}
addresses
Subscriptions GET /subscriptions
GET /subscriptions/{id}
subscription/activated
subscription/cancelled
subscription/created
subscription/deleted
subscription/skipped
subscription/updated
subscription/unskipped
customer
metafields

Cursor Pagination

By default, calls for a list of objects will return 50 results. Using the limit parameter, that can be increased to 250 results per response.

When there are more results than the current limit a cursor may be used to request additional results.

The next_cursor and previous_cursor attributes are are included in all list responses.

To request the next set of results, find the next_cursor in the list response and include it in the url with the cursor parameter e.g. GET https://api.rechargeapps.com/subscriptions?limit=250&cursor=<next_cursor>

To request the previous set of results, find the previous_cursor in the list response and include it in the url with the cursor parameter e.g. GET https://api.rechargeapps.com/subscriptions?limit=250&cursor=<previous_cursor>


Retrieving total number of records

Starting with the 2021-11 version of the API, you will not be able to retrieve a count of total records for a given GET request. If you are building a UI page that allows end users to paginate through result sets (such as paginating through a list of orders or subscriptions), we recommend that your pagination implementation allow users to go to the next and previous page of results (as opposed to allowing users to jump to specific page in the results). This aligns well with the previous_cursor and the next_cursor fields included in all list responses.

Example Request
URL="https://api.rechargeapps.com/charges?limit=5"

response=$(curl -s -w "%{http_code}"\ 
    -H 'X-Recharge-Access-Token: your_api_token' \ 
    -H 'X-Recharge-Version: 2021-11' \    -X GET $URL)

content=$(sed '$ d' <<< "$response") # get all but the last line which contains the status code

# Display results
echo $content | jq "."

# parse next url
echo "Next URL"
next_cursor=$(jq ".next_cursor" <<< "${content}")

# Notice next_cursor value is passed as page_info query param
echo "$URL&page_info=$next_cursor"

Sorting

The API supports sorting of results when using a GET request to retrieve a list. Sorting is achieved using a sort_by query parameter in the request URL. The sort_by value contains the parameter and sort direction for your results (ascending or descending), and available sort_by values vary between resources. The below table defines available sort_by options for commonly used resources.


Resource Supported sort_by_values
Address Default: id-desc
Options: id-asc id-desc updated_at-asc updated_at-desc
Async Batch Default: id-desc
Options: id-asc id-desc created_at-asc created_at-desc
Charge Default: id-asc
Options: id-asc id-desc created_at-asc created_at-desc updated_at-asc updated_at-desc charge_date-asc charge-date-desc
Customer Default: id-desc
Options: id-asc id-desc created_at-asc created_at-desc updated_at-asc updated_at-desc
Discount Default: id-desc
Options: id-asc id-desc created_at-asc created_at-desc updated_at-asc updated_at-desc
Metafield Default: id-desc
Options:id-asc id-desc updated_at-asc updated_at-desc
Onetime Default: id-desc
Options: id-asc id-desc created_at-asc created_at-desc updated_at-asc updated_at-desc
Order Default: id-desc
Options: id-asc id-desc updated_at-asc updated_at-desc processed_at-asc processed_at-desc scheduled_at-asc scheduled_at-desc
Plan Default: id-desc
Options:id-asc id-desc updated_at-asc updated_at-desc
Product Default: id-desc
Options: id-asc id-desc created_at-asc created_at-desc updated_at-asc updated_at-desc title-asc title-desc
Subscription Default: id-desc
Options: id-asc id-desc created_at-asc created_at-desc updated_at-asc updated_at-desc
Webhook Default: id-desc
Options: id-asc id-desc

Addresses

An Addresses record represents a shipping address. Each customer can have multiple addresses. Subscriptions are a child object of an address.

Endpoints
POST
/addresses
GET
/addresses/{id}
PUT
/addresses/{id}
DELETE
/addresses/{id}
GET
/addresses
POST
/addresses/merge
POST
/addresses/{id}/charges/skip

Bundle Selections

Pro plan

A bundle selection represents the contents within a Bundle linked to an individual Subscription. It can represent the selection for upcoming orders or past orders. A BundleSelection is associated with a corresponding Subscription and a BundleVariant (the BundleVariant is used to validate contents in the selection). When a new order for the associated Subscription occurs, it will extract the current contents of the BundleSelection for the Bundle item in the order.

Endpoints
GET
/bundle_selections
GET
/bundle_selections/{id}
POST
/bundle_selections
PUT
/bundle_selections/{id}
DELETE
/bundle_selections/{id}

The bundle selection object

Pro plan

A bundle selection represents the contents within a Bundle linked to an individual Subscription. It can represent the selection for upcoming orders or past orders. A BundleSelection is associated with a corresponding Subscription and a BundleVariant (the BundleVariant is used to validate contents in the selection).

Attributes
  • id
    integer

    The unique numeric identifier for the BundleSelection.

  • bundle_variant_id
    integer

    The ID of the BundleVariant associated with the BundleSelection.

  • purchase_item_id
    integer

    The ID of the PurchaseItem associated with the BundleSelection.

  • created_at
    datetime

    The date and time when the contents were selected.

  • external_product_id
    string

    The product id as it appears in the external e-commerce platform. The external_product_id of the Product record in Recharge, linking the BundleSelection to a Product associated with a Bundle.

  • external_variant_id
    string

    The variant id as it appears in the external e-commerce platform. The external_variant_id of the Product record in Recharge, linking the BundleSelection to a Product associated with a Bundle.

  • items
    array

    A list of item objects, each containing information about a distinct product selected as part of the Bundle.

  • updated_at
    datetime

    The date and time at which the BundleSelection was most recently updated.

The bundle selection object
{
  "bundle_selection": {
    "id": 100714428,
    "bundle_variant": 382417,
    "purchase_item_id": 199820883,
    "created_at": "2022-08-26T18:31:28",
    "external_product_id": "7121697210548",
    "external_variant_id": "41450875650228",
    "items": [
      {
        "id": 541,
        "collection_id": "287569608884",
        "collection_source": "shopify",
        "created_at": "2022-08-26T18:31:28",
        "external_product_id": "7121693671604",
        "external_variant_id": "41450853105844",
        "quantity": 3,
        "updated_at": "2022-08-26T18:52:41"
      }
    ],
    "updated_at": "2022-08-26T18:31:28"
  }
}

List bundle selections

Pro plan

Returns a list of BundleSelections.

HTTP request examples


GET /bundle_selections?purchase_item_ids=:purchase_item_id_1,:purchase_item_id_2

GET /bundle_selections?bundle_variant_ids=:bundle_variant_id_1,:bundle_variant_id_2

GET /bundle_selections?limit=1

GET /bundle_selections?limit=1&page=2

GET /bundle_selections?sort_by=updated_at-desc

Returned BundleSelections are sorted descending by ID value by default.

BundleSelections endpoints are available for Recharge Pro merchants. If you’re interested in leveraging the Recharge bundle_selections endpoints, reach out to your account manager or our Support team.
Learn more about Recharge Pro.

Scopes: read_subscriptions
Query Parameters
  • purchase_item_ids
    string

    Filter BundleSelections by Subscription or Onetime ID.

    If passing multiple values, must be comma separated. Non-integer values will result in a 422 error.

  • bundle_variant_ids
    string

    Filter BundleSelections by BundleVariants.

    If passing multiple values, must be comma separated. Non-integer values will result in a 422 error.

  • limit
    string

    Default: 50

    Max: 250

    The amount of results.

  • page
    string

    Default: 1

    The page to show.

  • sort_by
    string

    Sort listed BundleSelections in a specific order.
    Available sort options: id-asc, id-desc, updated_at-asc, updated_at-desc.

Responses
  • 200

    successful response

GET
/bundle_selections
curl 'https://api.rechargeapps.com/bundle_selections' \ 
 -H 'X-Recharge-Version: 2021-11' \ 
 -H 'X-Recharge-Access-Token: your_api_token' \ 
 -d limit=3 -G
Response
{
  "next_cursor": null,
  "previous_cursor": null,
  "bundle_selections": [
    {
      "id": 100714428,
      "bundle_variant": 382417,
      "purchase_item_id": 199820883,
      "created_at": "2022-08-26T18:31:28",
      "external_product_id": "7121697210548",
      "external_variant_id": "41450875650228",
      "items": [
        {
          "id": 541,
          "collection_id": "287569608884",
          "collection_source": "shopify",
          "created_at": "2022-08-26T18:31:28",
          "external_product_id": "7121693671604",
          "external_variant_id": "41450853105844",
          "quantity": 3,
          "updated_at": "2022-08-26T18:52:41"
        }
      ],
      "updated_at": "2022-08-26T18:31:28"
    }
  ]
}

Retrieve a bundle selection

Pro plan

Retrieve a BundleSelection using the bundle_selection_id.

BundleSelections endpoints are available for Recharge Pro merchants. If you’re interested in leveraging the Recharge bundle_selections endpoints, reach out to your account manager or our Support team.
Learn more about Recharge Pro.

Scopes: read_subscriptions
Responses
  • 200

    successful response

  • 404

    the BundleSelection with bundle_selection_id does not exist

GET
/bundle_selections/{id}
curl 'https://api.rechargeapps.com/bundle_selections/100714428' \ 
 -H 'X-Recharge-Version: 2021-11' \ 
 -H 'X-Recharge-Access-Token: your_api_token'
Response
{
  "bundle_selection": {
    "id": 100714428,
    "bundle_variant": 382417,
    "purchase_item_id": 199820883,
    "created_at": "2022-08-26T18:31:28",
    "external_product_id": "7121697210548",
    "external_variant_id": "41450875650228",
    "items": [
      {
        "id": 541,
        "collection_id": "287569608884",
        "collection_source": "shopify",
        "created_at": "2022-08-26T18:31:28",
        "external_product_id": "7121693671604",
        "external_variant_id": "41450853105844",
        "quantity": 3,
        "updated_at": "2022-08-26T18:52:41"
      }
    ],
    "updated_at": "2022-08-26T18:31:28"
  }
}

Create a bundle selection

Pro plan

Create a BundleSelection.

BundleSelections endpoints are available for Recharge Pro merchants. If you’re interested in leveraging the Recharge bundle_selections endpoints, reach out to your account manager or our Support team.
Learn more about Recharge Pro.

Scopes: write_subscriptions
Body Parameters
  • purchase_item_id
    integer
    * Required

    The ID of the PurchaseItem associated with the BundleSelection.

  • items
    array
    * Required

    A list of item objects, each containing information about a distinct product selected as part of the Bundle.

Responses
  • 200

    successful response

  • 422

    missing required field or invalid items passed

POST
/bundle_selections
curl 'https://api.rechargeapps.com/bundle_selections' \ 
 -H 'X-Recharge-Version: 2021-11' \ 
 -H 'Content-Type: application/json' \ 
 -H 'X-Recharge-Access-Token: your_api_token' \ 
 -d '{
  "purchase_item_id": "199820883",
  "items": [
    {
      "collection_id": "287569608884",
      "collection_source": "shopify",
     "external_product_id": "7121693671604",
      "external_variant_id": "41450853105844",
      "quantity": 3
    }
  ]
}'
Response
{
  "bundle_selection": {
    "id": 100714428,
    "bundle_variant": 382417,
    "purchase_item_id": 199820883,
    "created_at": "2022-08-26T18:31:28",
    "external_product_id": "7121697210548",
    "external_variant_id": "41450875650228",
    "items": [
      {
        "id": 541,
        "collection_id": "287569608884",
        "collection_source": "shopify",
        "created_at": "2022-08-26T18:31:28",
        "external_product_id": "7121693671604",
        "external_variant_id": "41450853105844",
        "quantity": 3,
        "updated_at": "2022-08-26T18:52:41"
      }
    ],
    "updated_at": "2022-08-26T18:31:28"
  }
}

Update a bundle selection

Pro plan

Modify an existing BundleSelection to match the specified parameters.

BundleSelections endpoints are available for Recharge Pro merchants. If you’re interested in leveraging the Recharge bundle_selections endpoints, reach out to your account manager or our Support team.
Learn more about Recharge Pro.

Scopes: write_subscriptions
Body Parameters
  • purchase_item_id
    integer

    The ID of the PurchaseItem associated with the BundleSelection.

  • items
    array

    A list of item objects, each containing information about a distinct product selected as part of the Bundle.

Responses
  • 200

    successful response

  • 404

    the BundleSelection with bundle_selection_id does not exist

  • 422

    invalid items passed

PUT
/bundle_selections/{id}
curl 'https://api.rechargeapps.com/bundle_selections' \ 
 -H 'X-Recharge-Version: 2021-11' \ 
 -H 'Content-Type: application/json' \ 
 -H 'X-Recharge-Access-Token: your_api_token' \ 
 -d '{
  "purchase_item_id": "199820883",
  "items": [
    {
      "collection_id": "287569608884",
      "collection_source": "shopify",
     "external_product_id": "7121693671604",
      "external_variant_id": "41450853105844",
      "quantity": 3
    }
  ]
}'
Response
{
  "bundle_selection": {
    "id": 100714428,
    "bundle_variant": 382417,
    "purchase_item_id": 199820883,
    "created_at": "2022-08-26T18:31:28",
    "external_product_id": "7121697210548",
    "external_variant_id": "41450875650228",
    "items": [
      {
        "id": 541,
        "collection_id": "287569608884",
        "collection_source": "shopify",
        "created_at": "2022-08-26T18:31:28",
        "external_product_id": "7121693671604",
        "external_variant_id": "41450853105844",
        "quantity": 3,
        "updated_at": "2022-08-26T18:52:41"
      }
    ],
    "updated_at": "2022-08-26T18:31:28"
  }
}

Delete a bundle selection

Pro plan

Delete a BundleSelection

BundleSelections endpoints are available for Recharge Pro merchants. If you’re interested in leveraging the Recharge bundle_selections endpoints, reach out to your account manager or our Support team.
Learn more about Recharge Pro.

Scopes: write_subscriptions
Responses
  • 204

    the BundleSelection has been removed and there is no content to send back in the response body.

  • 404

    the BundleSelection with id does not exist

DELETE
/bundle_selections/{id}
curl -X DELETE 'https://api.rechargeapps.com/bundle_selections/100714428' \ 
 -H 'X-Recharge-Version: 2021-11' \ 
 -H 'X-Recharge-Access-Token: your_api_token'
Response
{}

Charges

A charge is the representation of a financial transaction linked to the purchase of an item (past or future). It can be a transaction that was processed already or the representation of an upcoming transaction. A Charge is linked to its corresponding Orders (one Order for pay as you go subscriptions and several for pre-paid). Orders are created once the corresponding Charge is successful. After successful payment, the first Order will be immediately submitted to the external platform if applicable (e.g. Shopify, BigCommerce).

Endpoints
GET
/charges/{id}
GET
/charges
POST
/charges/{id}/apply_discount
POST
/charges/{id}/remove_discount
POST
/charges/{id}/skip
POST
/charges/{id}/unskip
POST
/charges/{id}/refund
POST
/charges/{id}/process
POST
/charges/{id}/capture_payment

Checkouts

Checkouts allow you to create, update, and process a Checkout programmatically. Shipping cost and sales tax determination are automatic functions of the Recharge Checkout resource.

Related guides: Recharge checkout integrations, How to use the Checkout resource

Important - The Checkout endpoints are only available for BigCommerce and Custom. Checkouts on Shopify must go through Shopify.

Endpoints
POST
/checkouts
GET
/checkouts/{token}
POST
/checkouts
PUT
/checkouts/{token}
GET
/checkouts/{token}/shipping_rates
POST
/checkouts/{token}/charge