### Install Rebill Web Components SDK using npm
Source: https://docs.rebill.com/sdk/quickstart
Install the Rebill web components SDK using npm. This is the first step to integrate the checkout functionality into your project.
```bash
npm install rebill-web-components-sdk
```
--------------------------------
### Implement Rebill Checkout in HTML
Source: https://docs.rebill.com/sdk/quickstart
Integrate the Rebill checkout component directly into an HTML page. This example shows how to add the component and attach event listeners for payment success, errors, and form changes using vanilla JavaScript.
```html
```
--------------------------------
### HTML with JavaScript for Dynamic Instant Plan
Source: https://docs.rebill.com/sdk/instant-checkout
Sets up the Rebill checkout component and dynamically configures an instant plan using JavaScript. This example demonstrates how to get the checkout element by its ID, create an `instantPlan` object with subscription details, and set it using `setAttribute`. It also includes event listeners for 'success' and 'error' events. Requires a valid 'public-key'.
```html
```
--------------------------------
### Implement Rebill Checkout in Next.js
Source: https://docs.rebill.com/sdk/quickstart
Integrate the Rebill checkout component within a React (Next.js) application. This example demonstrates using refs to access the component and attach event listeners for success, error, and form change events.
```javascript
"use client"
import 'rebill-web-components-sdk';
export default function Checkout() {
const checkoutRef = useRef(null);
const handleSuccess = (event) => {
const { paymentMethod, data } = event.detail;
// Your code here
};
const handleError = (event) => {
const { paymentMethod, data } = event.detail;
// Your code here
};
const handleFormChange = (event) => {
const { data, isValid } = event.detail;
// Your code here
};
useEffect(() => {
const element = checkoutRef.current;
if (!element) return;
element.addEventListener('success', handleSuccess);
element.addEventListener('error', handleError);
element.addEventListener('formChange', handleFormChange);
return () => {
element.removeEventListener('success', handleSuccess);
element.removeEventListener('error', handleError);
element.removeEventListener('formChange', handleFormChange);
};
}, [checkoutRef]);
return (
);
}
```
--------------------------------
### Create a Plan
Source: https://docs.rebill.com/api/quickstart
Create a new plan or product to represent what you sell. The payment link will be associated with this plan.
```APIDOC
## POST /v3/plans
### Description
Creates a new plan or product to be associated with payment links.
### Method
POST
### Endpoint
https://api.rebill.com/v3/plans
### Parameters
#### Request Body
- **name** (array) - Required - An array of objects, each with a `language` (string) and `text` (string), defining the plan's name.
- **description** (array) - Required - An array of objects, each with a `language` (string) and `text` (string), defining the plan's description.
- **frequency** (object) - Required - An object defining the billing frequency.
- **period** (string) - Required - The period of the frequency (e.g., "months", "years").
- **count** (integer) - Required - The number of periods for the frequency.
- **type** (string) - Required - The type of plan (e.g., "units").
- **status** (string) - Required - The status of the plan (e.g., "active").
- **prices** (array) - Required - An array of price objects.
- **amount** (integer) - Required - The price amount in the smallest currency unit.
- **currency** (string) - Required - The ISO currency code (e.g., "ARS", "CLP").
- **isDefault** (boolean) - Optional - Indicates if this is the default price.
### Request Example
```json
{
"name": [
{
"language": "en",
"text": "Monthly Premium Plan"
}
],
"description": [
{
"language": "en",
"text": "Premium subscription billed monthly"
}
],
"frequency": {
"period": "months",
"count": 1
},
"type": "units",
"status": "active",
"prices": [
{
"amount": 1990,
"currency": "ARS",
"isDefault": true
},
{
"amount": 1790,
"currency": "CLP"
}
]
}
```
### Response
#### Success Response (200)
- **plan** (object) - Contains details of the created plan, including its unique `id`.
- **id** (string) - The unique identifier for the created plan.
- **name** (array) - The name of the plan.
- **description** (array) - The description of the plan.
- **status** (string) - The status of the plan.
- **frequency** (object) - The billing frequency details.
- **type** (string) - The type of plan.
#### Response Example
```json
{
"plan": {
"id": "pln_4b970527a2fe4923ba7477c0c86ec933",
"name": [
{
"language": "en",
"text": "Monthly Premium Plan"
}
],
"description": [
{
"language": "en",
"text": "Premium subscription billed monthly"
}
],
"status": "active",
"frequency": {
"period": "months",
"count": 1
},
"type": "units"
}
}
```
```
--------------------------------
### Create a Payment Link for a Plan
Source: https://docs.rebill.com/api/quickstart
Generate a payment link associated with a previously created plan or product.
```APIDOC
## POST /v3/payment-links
### Description
Creates a payment link for a specified plan or product.
### Method
POST
### Endpoint
https://api.rebill.com/v3/payment-links
### Parameters
#### Request Body
- **title** (array) - Required - An array of objects, each with a `language` (string) and `text` (string), defining the payment link's title.
- **plan** (object) - Required - An object containing the `id` of the plan to associate with the payment link.
- **id** (string) - Required - The ID of the plan.
- **paymentMethods** (array) - Required - An array of objects specifying allowed payment methods and currencies.
- **methods** (array) - Required - An array of strings representing payment methods (e.g., "card", "bank_transfer").
- **currency** (string) - Required - The ISO currency code for this payment method configuration.
### Request Example
```json
{
"title": [
{
"language": "en",
"text": "Test Payment Link"
}
],
"plan": {
"id": "{planId}"
},
"paymentMethods": [
{
"methods": ["card", "bank_transfer"],
"currency": "ARS"
},
{
"methods": ["card", "bank_transfer"],
"currency": "CLP"
}
]
}
```
### Response
#### Success Response (200)
- **url** (string) - The URL of the generated payment link.
#### Response Example
```json
{
"url": "https://pay.rebill.com/my-business-alias/pl_5555fd46072648408c127833"
}
```
```
--------------------------------
### APM Checkout Request Response Example
Source: https://docs.rebill.com/api/reference/checkout
This is an example of a successful response from the POST /checkout/request endpoint, indicating that the checkout request has been created and is pending customer action. The response includes a trace ID, date, and the checkout request ID along with its initial status.
```json
{
"traceId": "checkout_1709058830244_r8h3k5m",
"date": "2024-02-24T22:33:50.244Z",
"result": {
"checkoutRequestId": "chk_req_2f5a8d1c4e7b9a3d6f8c1e4a7b2d5c8e",
"status": "PENDING",
"data": {
"redirectUrl": "https://pse.com/98765432"
}
}
}
```
--------------------------------
### Subscription Response Example (JSON)
Source: https://docs.rebill.com/api/reference/subscriptions
Example JSON response for a subscription, detailing plan information, billing cycles, payment method, customer details, and metadata. This structure is typically returned by Rebill API endpoints related to subscription retrieval or creation.
```json
{
"data": [
{
"id": "sub_ad128372a40b8dbac50a8ca20c7305b",
"name": "Premium Plan",
"description": "Premium subscription plan",
"status": "active",
"lastChargeDate": "2024-03-05T15:59:59.000Z",
"nextChargeDate": "2024-04-05T15:59:59.000Z",
"amount": 15000,
"lastChargedAmount": 15000,
"currency": "ARS",
"setupFee": 0,
"frequency": {
"period": "month",
"count": 1
},
"billingCycles": {
"total": 12,
"current": 1,
"remaining": 11
},
"plan": {
"id": "plan_647838573cf58d61bc659f6525f528ba",
"title": "Premium Plan",
"amount": 15000,
"currency": "ARS",
"frequency": {
"period": "month",
"count": 1
},
"repetitions": 12
},
"paymentMethod": "card",
"card": {
"id": "card_647838573cf58d61bc659f6525f528ba",
"brand": "visa",
"type": "credit",
"lastFourDigits": "4242"
},
"discount": {
"couponCode": "DESC10",
"type": "percentage",
"percentage": 10,
"billingCyclesToApply": {
"total": 12,
"remaining": 11
}
},
"customer": {
"id": "cus_647838573cf58d61bc659f6525f528ba",
"name": "John Doe",
"email": "john.doe@example.com",
"phone": "+1234567890"
},
"createdAt": "2024-03-05T15:59:59.000Z",
"metadata": {
"customField": "value"
}
}
],
"total": 100,
"limit": 10,
"offset": 0
}
```
--------------------------------
### Create a Plan using cURL
Source: https://docs.rebill.com/api/quickstart
This snippet demonstrates how to create a new plan using a cURL request. It requires your API key and specifies plan details such as name, description, pricing, and frequency. The response includes the unique ID of the created plan.
```curl
curl -X POST https://api.rebill.com/v3/plans \
-H "accept: application/json" \
-H "content-type: application/json" \
-H "x-api-key: {{API_KEY}}" \
-d '{
"name": [
{
"language": "en",
"text": "Monthly Premium Plan"
}
],
"description": [
{
"language": "en",
"text": "Premium subscription billed monthly"
}
],
"frequency": {
"period": "months",
"count": 1
},
"type": "units",
"status": "active",
"prices": [
{
"amount": 1990,
"currency": "ARS",
"isDefault": true
},
{
"amount": 1790,
"currency": "CLP"
}
]
}'
```
--------------------------------
### Response for Get Organization Data
Source: https://docs.rebill.com/api/reference/my-organization
This is an example of the response received when successfully retrieving organization data. It mirrors the organization object structure, indicating the current status and environment of the organization.
```json
{
"id": "org_a2a2627fe8444c64be3b6ece42d973c4",
"name": "Demo Rebill",
"alias": "organization-alias",
"status": "in_progress",
"environment": "sandbox",
"logoUrl": null
}
```
--------------------------------
### Prevent Duplicate Subscription Charges with Idempotency Key
Source: https://docs.rebill.com/guides/troubleshooting
This code snippet demonstrates how to use an idempotency key when creating a payment to prevent duplicate charges for a subscription. It includes the subscription ID and billing cycle start date in the key. This is crucial for programmatic payment creation.
```javascript
const payment = await rebill.payments.create({
subscription_id: 'sub_123',
amount: subscription.amount,
idempotency_key: `sub_${subscription.id}_${subscription.current_period_start}`
});
```
--------------------------------
### Create an Instant Payment Link
Source: https://docs.rebill.com/api/quickstart
Create instant payment links for one-time payments of a specific amount without associating them with a product or plan.
```APIDOC
## POST /v3/instant-payment-links
### Description
Creates an instant payment link for a one-time charge without a pre-defined plan or product.
### Method
POST
### Endpoint
https://api.rebill.com/v3/instant-payment-links
### Parameters
#### Request Body
- **title** (array) - Required - An array of objects, each with a `language` (string) and `text` (string), defining the payment link's title.
- **amount** (integer) - Required - The amount for the one-time payment in the smallest currency unit.
- **currency** (string) - Required - The ISO currency code (e.g., "ARS", "CLP").
- **description** (array) - Optional - An array of objects, each with a `language` (string) and `text` (string), describing the charge.
- **paymentMethods** (array) - Optional - An array of objects specifying allowed payment methods and currencies.
- **methods** (array) - Required - An array of strings representing payment methods (e.g., "card", "bank_transfer").
- **currency** (string) - Required - The ISO currency code for this payment method configuration.
### Request Example
```json
{
"title": [
{
"language": "en",
"text": "One-time Service Fee"
}
],
"amount": 5000,
"currency": "USD",
"description": [
{
"language": "en",
"text": "Payment for consulting services rendered."
}
],
"paymentMethods": [
{
"methods": ["card"],
"currency": "USD"
}
]
}
```
### Response
#### Success Response (200)
- **url** (string) - The URL of the generated instant payment link.
#### Response Example
```json
{
"url": "https://pay.rebill.com/my-business-alias/ipl_a1b2c3d4e5f67890"
}
```
```
--------------------------------
### GET /v3/data/states/:isoCountry
Source: https://docs.rebill.com/api/test-tools-and-resources
Get state/province list for address validation and KYC.
```APIDOC
## GET /v3/data/states/:isoCountry
### Description
Get state/province list for address validation and KYC.
### Method
GET
### Endpoint
`/v3/data/states/:isoCountry`
### Parameters
#### Path Parameters
- **isoCountry** (string) - Required - The ISO country code for which to retrieve states.
### Response
#### Success Response (200)
- **country** (string) - The name of the country.
- **isoCountryCode** (string) - The ISO country code.
- **states** (array) - A list of states or provinces within the specified country.
#### Response Example
```json
{
"country": "Argentina",
"isoCountryCode": "AR",
"states": ["Buenos Aires", "Córdoba", "Santa Fe", ...]
}
```
```
--------------------------------
### GET /v3/data/country-codes/:isoCountry
Source: https://docs.rebill.com/api/test-tools-and-resources
Get country calling codes for phone number validation.
```APIDOC
## GET /v3/data/country-codes/:isoCountry
### Description
Get country calling codes for phone number validation.
### Method
GET
### Endpoint
`/v3/data/country-codes/:isoCountry`
### Parameters
#### Path Parameters
- **isoCountry** (string) - Required - The ISO country code for which to retrieve the calling code.
### Response
#### Success Response (200)
- **countryCode** (string) - The country calling code.
- **isoCountryCode** (string) - The ISO country code.
#### Response Example
```json
{
"countryCode": "54",
"isoCountryCode": "AR"
}
```
```
--------------------------------
### GET /v3/addresses
Source: https://docs.rebill.com/api/reference/addresses
Retrieves a list of all addresses associated with your Rebill organization. This endpoint is useful for getting an overview of all stored addresses.
```APIDOC
## GET /v3/addresses
### Description
Returns a list of all addresses in your organization.
### Method
GET
### Endpoint
/v3/addresses
### Parameters
#### Headers
- **x-api-key** (string) - Required - API key for authentication. Format: `x-api-key: {{API_KEY}}`
### Response
#### Success Response (200)
- **addresses** (array) - A list of address objects. Returns an empty array if no addresses exist.
- Each object in the array has the following properties:
- **id** (string) - Unique identifier for the object.
- **country** (string) - ISO 3166-1 alpha-2 country code.
- **state** (string) - State or province name.
- **city** (string) - City name.
- **zipCode** (string) - Postal or ZIP code.
- **lineOne** (string) - Primary street address.
- **lineTwo** (string) - Secondary address line (apartment, suite, floor), if any.
- **type** (string) - Either `billing` or `shipping`.
- **customerId** (string) - Unique identifier for the associated customer.
#### Error Response (401)
- **Unauthorized** - Invalid or missing API key.
### Request Example
```curl
curl -X GET "https://api.rebill.com/v3/addresses" \
-H "x-api-key: {{API_KEY}}"
```
### Response Example (200 OK)
```json
[
{
"id": "addr_12aa31cdfb574e4191e96e67523a3560",
"country": "AR",
"state": "Buenos Aires",
"city": "Buenos Aires",
"zipCode": "1000",
"lineOne": "Av. Corrientes 1234",
"lineTwo": "Apartment",
"type": "billing",
"customerId": "cus_12aa31cdfb574e4191e96e67523a3560"
},
{
"id": "addr_2a94dfaf407c4f84a41578aad0a6122b",
"country": "AR",
"state": "Buenos Aires",
"city": "Buenos Aires",
"zipCode": "1414",
"lineOne": "El Salvador 1234",
"lineTwo": "Office",
"type": "shipping",
"customerId": "cus_12aa31cdfb574e4191e96e67523a3560"
}
]
```
```
--------------------------------
### Securely Initialize Rebill Client with Environment Variables (Node.js)
Source: https://docs.rebill.com/guides/going-live
Demonstrates how to securely initialize the Rebill client by loading API keys and secret keys from environment variables using the 'dotenv' package. This prevents hardcoding sensitive credentials.
```javascript
// Store credentials in environment variables
require('dotenv').config();
const rebill = new RebillClient({
apiKey: process.env.REBILL_API_KEY,
secretKey: process.env.REBILL_SECRET_KEY
});
```
--------------------------------
### Create a Payment Link for a Plan using cURL
Source: https://docs.rebill.com/api/quickstart
This snippet shows how to create a payment link for an existing plan using cURL. You need to provide your API key and the plan ID. It allows specifying accepted payment methods and currencies for the link. The response contains the URL for the payment link.
```curl
curl -X POST https://api.rebill.com/v3/payment-links \
-H "accept: application/json" \
-H "content-type: application/json" \
-H "x-api-key: {{API_KEY}}" \
-d '{
"title": [
{
"language": "en",
"text": "Test Payment Link"
}
],
"plan": {
"id": "{planId}"
},
"paymentMethods": [
{
"methods": ["card", "bank_transfer"],
"currency": "ARS"
},
{
"methods": ["card", "bank_transfer"],
"currency": "CLP"
}
]
}'
```
--------------------------------
### Organization Object Example
Source: https://docs.rebill.com/api/reference/my-organization
This is an example of the organization object structure, showing its attributes and their typical values. It includes fields for ID, name, alias, status, environment, and logo URL.
```json
{
"id": "org_a2a2627fe8444c64be3b6ece42d973c4",
"name": "Demo Rebill",
"alias": "organization-alias",
"status": "active",
"environment": "sandbox",
"logoUrl": null
}
```
--------------------------------
### APM Checkout Status Response Example
Source: https://docs.rebill.com/api/reference/checkout
This is an example of a successful response when retrieving the status of an APM checkout request. It shows the checkoutRequestId, the current status (e.g., 'approved'), the payment type, and additional data relevant to the payment.
```json
{
"checkoutRequestId": "chk_req_2f5a8d1c4e7b9a3d6f8c1e4a7b2d5c8e",
"status": "approved",
"type": "bank_transfer",
"data": {
"url": "https://pse.com/98765432",
"message": "Payment completed successfully"
}
}
```
--------------------------------
### Import Rebill Web Components SDK
Source: https://docs.rebill.com/sdk/quickstart
Import the checkout component from the Rebill web components SDK into your main project file. This makes the component available for use.
```javascript
import 'rebill-web-components-sdk';
```
--------------------------------
### Webhook Object Example
Source: https://docs.rebill.com/api/reference/webhooks
This is an example of the webhook object structure returned by Rebill's API. It includes the webhook's ID, the notification URL, its active status, the subscribed events, and the organization ID.
```json
{
"id": "we_f2b90261588e45edaf93c488e577ac66",
"url": "https://hook.us1.make.com/1gh9w22g24qdrvll62n0ed7x6z3h53n4",
"active": true,
"events": [
"payment.created"
],
"organizationId": "org_8fa0d70f8ab54c7d8e54bc356422b2bd"
}
```
--------------------------------
### List Plans Request Example (cURL)
Source: https://docs.rebill.com/api/reference/plans
This cURL command demonstrates how to list existing subscription plans. It includes the necessary headers for authentication and specifies the endpoint. The request can be further customized with search parameters and filters for pagination and specific criteria.
```cURL
curl -X POST https://api.rebill.com/v3/plans/search \
-H "x-api-key: {{API_KEY}}"
```
--------------------------------
### Example Coupon Object Response
Source: https://docs.rebill.com/api/reference/coupons
An example JSON object representing a coupon. This object details a '10% OFF Discount' coupon with specific application cycles and usage limits, demonstrating the structure of a successful coupon retrieval response.
```json
{
"id": "cpn_64d92e630b054c60ba083a8ac543f63e",
"name": "10% OFF Discount",
"description": "10% OFF Discount",
"notes": null,
"format": "PERCENTAGE",
"code": "CODE10",
"productIds": [],
"planIds": [],
"paymentLinkIds": [],
"customerId": null,
"expirationDate": "2025-11-25",
"redemptions": 0,
"status": "active",
"percentage": 10,
"fixedAmountsPerCurrency": null,
"applicableCycles": 5,
"availableUses": 10,
"lastArchivedAt": null,
"lastUnarchivedAt": null,
"isArchived": false,
"createdAt": "2025-09-03T18:56:07.639Z"
}
```
--------------------------------
### Create Subscription with Coupon (JavaScript)
Source: https://docs.rebill.com/guides/coupons
Demonstrates how to create a subscription and attach a coupon to it, ensuring the discount persists across renewals. This is the recommended method for applying coupons to subscriptions.
```javascript
const subscription = await rebill.subscriptions.create({
plan_id: 'plan_monthly',
customer_id: customer.id,
coupon: 'SAVE20'
});
```
--------------------------------
### Example Product Data Structure (JSON)
Source: https://docs.rebill.com/api/test-tools-and-resources
This JSON object represents a sample product with its name and language. It's a basic structure used for defining products within the Rebill system.
```json
{
"name": "Producto de prueba",
"language": "es"
}
```
--------------------------------
### Example States Response (JSON)
Source: https://docs.rebill.com/api/test-tools-and-resources
This JSON response provides a list of states for a given country, along with the country's name and ISO code. It's the output from the states retrieval endpoint.
```json
{
"country": "Argentina",
"isoCountryCode": "AR",
"states": ["Buenos Aires", "Córdoba", "Santa Fe", ...the list of states]
}
```
--------------------------------
### Get Customer Identifications using cURL
Source: https://docs.rebill.com/api/reference/customers
This snippet shows how to retrieve identification documents for a specific customer using a GET request to the Rebill API. It requires an API key for authentication. The response is a JSON array containing identification objects, or an error if the customer is not found.
```curl
curl -X GET https://api.rebill.com/v3/customers/:id/identifications \
-H "x-api-key: {{API_KEY}}" \
-H "accept: application/json"
```
--------------------------------
### Retrieve Product Data Example (JSON)
Source: https://docs.rebill.com/api/reference/products
This JSON object represents a successful response when retrieving product information. It includes details like product ID, name, description, status, pricing, and metadata. The structure allows for multi-language support for names and descriptions.
```json
{
"data": [
{
"id": "prd_52b0d61e4d79422885535a6a3794f89e",
"name": [
{
"language": "en",
"text": "Blue Premium Package"
}
],
"description": [
{
"language": "en",
"text": "Premium product with additional features"
}
],
"status": "active",
"prices": [
{
"id": "prc_52b0d61e4d79422885535a6a3794f89e",
"amount": 15000,
"currency": "ARS",
"isDefault": true,
"createdAt": "2024-02-15T10:25:28.769Z",
"updatedAt": "2024-03-19T14:32:45.112Z"
}
],
"metadata": {
"category": "SaaS",
"SKU": "BLU-PREM-001"
},
"createdAt": "2024-02-15T10:25:28.769Z",
"updatedAt": "2024-03-19T14:32:45.112Z"
},
{
"id": "prd_a1b2c3d4e5f6422885535a6a3794f89e",
"name": [
{
"language": "en",
"text": "Enterprise API Access"
}
],
"description": [
{
"language": "en",
"text": "API access with tiered pricing based on usage"
}
],
"status": "active",
"prices": [
{
"id": "prc_a1b2c3d4e5f6422885535a6a3794f89e",
"amount": 5000,
"currency": "ARS",
"isDefault": true,
"createdAt": "2024-03-01T08:15:22.123Z",
"updatedAt": "2024-03-19T14:32:45.112Z"
}
],
"metadata": {
"category": "API",
"maxRequests": 1000000
},
"createdAt": "2024-03-01T08:15:22.123Z",
"updatedAt": "2024-03-19T14:32:45.112Z"
}
],
"total": 2,
"limit": 10,
"offset": 0
}
```
--------------------------------
### Get Available Team Roles (API Request)
Source: https://docs.rebill.com/api/reference/team-members
This cURL command demonstrates how to retrieve a list of all available team roles within the Rebill organization. It sends a GET request to the specified API endpoint with an 'accept' header for JSON. The response will be an array of role objects.
```curl
curl -X GET 'https://api.rebill.com/v3/members/roles' \
-H 'accept: application/json'
```
--------------------------------
### POST /v3/checkout
Source: https://docs.rebill.com/api/reference/checkout
Creates an instant subscription checkout. This endpoint allows for the creation of a subscription with specified details, customer information, and payment card details.
```APIDOC
## POST /v3/checkout
### Description
Creates an instant subscription checkout. This endpoint allows for the creation of a subscription with specified details, customer information, and payment card details.
### Method
POST
### Endpoint
https://api.rebill.com/v3/checkout
### Parameters
#### Request Body
- **subscription** (object) - Required - Details of the subscription.
- **name** (array) - Required - Name of the subscription.
- **language** (string) - Required - Language code (e.g., "en").
- **text** (string) - Required - Subscription name text.
- **amount** (number) - Required - Subscription amount.
- **currency** (string) - Required - Currency code (e.g., "ARS").
- **frequency** (object) - Required - Subscription frequency.
- **period** (string) - Required - Frequency period (e.g., "month").
- **count** (number) - Required - Frequency count.
- **repetitions** (number) - Required - Number of repetitions for the subscription.
- **type** (string) - Required - Type of subscription (e.g., "units").
- **quantity** (number) - Required - Quantity for the subscription.
- **customer** (object) - Required - Customer details.
- **firstName** (string) - Required - Customer's first name.
- **lastName** (string) - Required - Customer's last name.
- **email** (string) - Required - Customer's email address.
- **phone** (object) - Required - Customer's phone number.
- **countryCode** (string) - Required - Phone country code.
- **number** (string) - Required - Phone number.
- **shippingAddress** (object) - Optional - Customer's shipping address.
- **lineOne** (string) - Required - Address line one.
- **lineTwo** (string) - Optional - Address line two.
- **city** (string) - Required - City.
- **state** (string) - Required - State.
- **zipCode** (string) - Required - Zip code.
- **country** (string) - Required - Country code.
- **card** (object) - Required - Payment card details.
- **name** (string) - Required - Name on the card.
- **expiration** (object) - Required - Card expiration date.
- **month** (string) - Required - Expiration month (e.g., "11").
- **year** (string) - Required - Expiration year (e.g., "2099").
- **cvv** (string) - Required - Card verification value.
- **number** (string) - Required - Card number.
- **billingDetails** (object) - Required - Billing details.
- **address** (object) - Required - Billing address.
- **lineOne** (string) - Required - Address line one.
- **lineTwo** (string) - Optional - Address line two.
- **city** (string) - Required - City.
- **state** (string) - Required - State.
- **zipCode** (string) - Required - Zip code.
- **country** (string) - Required - Country code.
- **identification** (object) - Required - Customer identification.
- **type** (string) - Required - Identification type (e.g., "DNI").
- **value** (string) - Required - Identification value.
- **paymentMetadata** (object) - Optional - Metadata for payment.
- **customField1** (string) - Optional - Custom field 1.
- **customField2** (string) - Optional - Custom field 2.
- **customAttributes** (object) - Optional - Custom attributes.
- **deviceId** (string) - Optional - Device ID.
### Request Example
```json
{
"subscription": {
"name": [
{
"language": "en",
"text": "Instant subscription"
}
],
"amount": 250,
"currency": "ARS",
"frequency": {
"period": "month",
"count": 1
},
"repetitions": 3,
"type": "units",
"quantity": 1
},
"customer": {
"firstName": "Ana",
"lastName": "López",
"email": "analopez@example.com",
"phone": {
"countryCode": "54",
"number": "1153190141"
},
"shippingAddress": {
"lineOne": "Av. Corrientes 1234",
"lineTwo": "Apartment",
"city": "Buenos Aires",
"state": "CABA",
"zipCode": "C1043AAZ",
"country": "AR"
}
},
"card": {
"name": "Ana López",
"expiration": {
"month": "11",
"year": "2099"
},
"cvv": "123",
"number": "4507990000004905"
},
"billingDetails": {
"address": {
"lineOne": "Av. Corrientes 1234",
"lineTwo": "Apartment",
"city": "Buenos Aires",
"state": "CABA",
"zipCode": "C1043AAZ",
"country": "AR"
},
"identification": {
"type": "DNI",
"value": "43044413"
}
},
"paymentMetadata": {
"customField1": "value1",
"customField2": "value2"
},
"customAttributes": {
"deviceId": "fpt_9ec48794-95e9-47ba-8092-f86c1088b65a"
}
}
```
### Response
#### Success Response (200)
- **traceId** (string) - Unique identifier for this checkout operation.
- **date** (string) - Time at which the response was generated, in ISO 8601 format.
- **result** (object) - Result of the checkout operation.
- **paymentId** (string) - Unique identifier for the payment.
- **status** (string) - Status of the payment (e.g., "approved").
- **subscriptionId** (string) - Unique identifier for the subscription.
- **cardId** (string) - Unique identifier for the card.
- **customerId** (string) - Unique identifier for the customer.
#### Response Example
```json
{
"traceId": "checkout_1709058830240_kj8n2x5",
"date": "2024-02-24T22:33:50.240Z",
"result": {
"paymentId": "pay_987f8a061d2c3da6ab044711e51f163d",
"status": "approved",
"subscriptionId": "sub_3k1568576a364e10aa96a149c753093j",
"cardId": "crd_251568576a364e10aa96a149c753krut",
"customerId": "cust_327f8a061d2c3da6ab044711e510sder"
}
}
```
```
--------------------------------
### Create Customer using cURL
Source: https://docs.rebill.com/api/reference/customers
This example shows how to create a new customer using a cURL command. It requires an API key and sends customer details such as first name, last name, and email in the request body. The response includes the newly created customer object.
```curl
curl -X POST https://api.rebill.com/v3/customers \
-H "x-api-key: {{API_KEY}}" \
-H "Content-Type: application/json" \
-d '{ \
"firstName": "John", \
"lastName": "Doe", \
"email": "john.doe@example.com", \
"phoneNumbers": [ \
{ \
"countryCode": "1", \
"number": "55550123" \
} \
], \
"addresses": [ \
{ \
"street": "123 Market St", \
"city": "San Francisco", \
"state": "CA", \
"country": "US", \
"zipCode": "94105", \
"extraInfo": "Suite 100" \
} \
] \
}'
```