ACTIONS
  • Home
  • My Actions
  • My Projects
  • My Packages
Stripe -> List All Customers
Readonly
Stripe - List All Customers

Action summary

Stripe -> List All Customers

Xano / Stripe

Stripe - List All Customers

How to Get the Stripe API Key

To retrieve your Stripe API key, follow these steps:

  1. Log in to your Stripe dashboard at https://dashboard.stripe.com.
  2. Navigate to Developers > API keys.
  3. Locate the Secret Key under the Standard keys section.
  4. Click Reveal test key (for testing) or use the live key for production.
  5. Copy the API key and store it securely.

Note: Never expose your API key in client-side applications.

Overview

This function retrieves a list of customers from Stripe with optional filtering and pagination parameters.

Inputs

The function accepts the following inputs:

Name Type Description
email text Filter customers by email (optional)
starting_after text The ID of the last customer retrieved (for pagination)
limit integer The number of customers to return (optional)
stripe_api_key registry/text The API key used to authenticate with Stripe

Function Stack

The function consists of the following steps:

1. Prepare Body Parameters

  • Create Variable:
    • Initializes body_params as an empty object {}.
  • Update Variable:
    • Adds email to body_params if provided.
    • Adds starting_after to body_params if provided.
    • Adds limit to body_params if provided.

2. Stripe API Call

  • API Request:
    • Endpoint: https://api.stripe.com/v1/customers
    • Method: GET
    • Authentication: Uses the stripe_api_key
    • Body Parameters:
      • email: Filter customers by email (optional).
      • starting_after: The ID of the last customer retrieved (optional).
      • limit: The number of customers to return (optional).
    • Returns: stripe_api

3. Precondition Check

  • Ensures that the API response status is 200 before proceeding.

4. Response

  • Key: As Self
  • Value: var: stripe_api.response.result
  • The function returns the list of customers received from Stripe if the API call is successful.

Usage

  1. Optionally provide email to filter customers.
  2. Optionally provide starting_after to paginate results.
  3. Optionally provide limit to specify the number of customers to return.
  4. Ensure that stripe_api_key is correctly set up in the registry.
  5. Call the function to retrieve the list of customers from Stripe.
  6. If successful, the function returns customer information in JSON format.

Example Response

{
  "object": "list",
  "data": [
    {
      "id": "cus_12345",
      "object": "customer",
      "email": "customer1@example.com",
      "created": 1672531199
    },
    {
      "id": "cus_67890",
      "object": "customer",
      "email": "customer2@example.com",
      "created": 1672531300
    }
  ],
  "has_more": false
}

Error Handling

  • If the API response status is not 200, the function does not proceed.
  • Ensure valid email, starting_after, and limit values to prevent API errors.

Notes

  • This function requires an active Stripe account and API key.
  • API keys should be kept secure and not exposed in client-side applications.
  • Use pagination to fetch large sets of customers efficiently.

Version notes

2025-03-03 17:39:54
Current
2025-03-03T12:09:56.000+00:00