> For the complete documentation index, see [llms.txt](https://docs.planetcrust.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.planetcrust.com/stripe/stripe/action-create-checkout-session.md).

# Action: Create Checkout Session

Stripe Operation

<p align="center"><a class="button primary" data-icon="circle-caret-right">Try @Human</a><a class="button primary" data-icon="check">Buy @Human Subscriptions</a><a class="button primary" data-icon="comments">Join @Human Community</a></p>

<figure><img src="https://173051806-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FEFQVbo960GBdKqZMghCQ%2Fuploads%2Fgit-blob-7aed60ee561d4eccf4c849f68eff2dced89e04f8%2FStripe.png?alt=media" alt=""><figcaption></figcaption></figure>

<p align="center">The Create Checkout Session action enables users to create a Stripe checkout session.</p>

{% embed url="<https://www.youtube.com/watch?v=CyuUuaBSZzA>" %}

#### Example User Story

I want to create a Stripe checkout session when a user selects to buy one of our products on our website.

#### Fields

| Field Name      | Field Type | Required |
| --------------- | ---------- | -------- |
| customer\_email | String     | Yes      |
| line\_items     | Array      | Yes      |
| success\_url    | String     | Yes      |
| cancel\_url     | String     | Yes      |
| mode            | String     | No       |

### Related Connections

[Stripe](/stripe/stripe.md)

### Related Automations

Example link

### Code (Apache v2.0): Operation

```
{
  "handle": "create-checkout-session",
  "state": "inDev",
  "meta": {
    "short": "Create Checkout Session",
    "description": "Creates a new checkout session in Stripe for payment processing."
  },
  "input": [
    {
      "name": "customer_email",
      "type": "String",
      "required": true,
      "meta": {
        "description": "Email address of the customer."
      }
    },
    {
      "name": "line_items",
      "type": "Array",
      "required": true,
      "meta": {
        "description": "List of items the customer is purchasing."
      }
    },
    {
      "name": "success_url",
      "type": "String",
      "required": true,
      "meta": {
        "description": "URL to redirect to after successful payment."
      }
    },
    {
      "name": "cancel_url",
      "type": "String",
      "required": true,
      "meta": {
        "description": "URL to redirect to if the customer cancels the payment."
      }
    },
    {
      "name": "mode",
      "type": "String",
      "required": false,
      "meta": {
        "description": "The mode of the checkout session (e.g., 'payment', 'subscription').",
        "default": "payment"
      }
    }
  ],
  "output": [
    {
      "name": "session_id",
      "type": "String",
      "selector": ["id"],
      "meta": {
        "description": "The unique identifier for the checkout session."
      }
    },
    {
      "name": "session_url",
      "type": "String",
      "selector": ["url"],
      "meta": {
        "description": "The URL to redirect the customer to for payment."
      }
    }
  ],
  "steps": [
    {
      "type": "http",
      "http": {
        "method": "POST",
        "path": "/v1/checkout/sessions",
        "headers": {
          "Content-Type": "application/x-www-form-urlencoded"
        },
        "bodyTemplate": {
          "value": "customer_email={{.customer_email}}&line_items={{.line_items}}&success_url={{.success_url}}&cancel_url={{.cancel_url}}&mode={{.mode}}",
          "placeholders": [
            {
              "name": "apiKey",
              "type": "String",
              "description": "Stripe API key for authentication.",
              "required": true
            },
            {
              "name": "customer_email",
              "type": "String",
              "description": "Email address of the customer.",
              "required": true
            },
            {
              "name": "line_items",
              "type": "Array",
              "description": "List of items the customer is purchasing.",
              "required": true
            },
            {
              "name": "success_url",
              "type": "String",
              "description": "URL to redirect to after successful payment.",
              "required": true
            },
            {
              "name": "cancel_url",
              "type": "String",
              "description": "URL to redirect to if the customer cancels the payment.",
              "required": true
            },
            {
              "name": "mode",
              "type": "String",
              "description": "The mode of the checkout session (e.g., 'payment', 'subscription').",
              "required": false,
              "default": "payment"
            }
          ]
        }
      }
    }
  ]
}

```

<p align="center"><a class="button primary" data-icon="square-caret-right">Try @Human</a><a class="button primary" data-icon="check">Buy @Human Subscription</a><a class="button primary" data-icon="comments">Join @Human Community</a></p>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.planetcrust.com/stripe/stripe/action-create-checkout-session.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
