Getting Started with the API

Learn how to set up and use the Lemon Squeezy API, from creating API keys to making authenticated requests and understanding the API’s structure and capabilities.


Before diving into this guide, ensure that you have a Lemon Squeezy account. New to Lemon Squeezy? Check out our Getting Started guide to set up your account.

Create an API key

To access our API endpoints, you’ll need to create an API key. You can create one by navigating to Settings » API in your Lemon Squeezy dashboard. This key will authenticate your requests and allow you to interact with our API securely.

Lemon Squeezy: Create API Key

Create a new API key and give it a clear name. If you think you’ll need more than one key, pick names that you and your team can easily understand. Keep in mind that you can’t change these names later, so choose them carefully.

After you submit the form, you’ll see your new API key. Make sure to copy it and save it somewhere safe. Remember, you’ll only see this key once in the Lemon Squeezy dashboard, so don’t lose it!

Lemon Squeezy: API Key Copy

If you lose an API key, you can always make new ones or remove old ones from the Settings » API page in your Lemon Squeezy dashboard.

Making requests

The Lemon Squeezy API can be accessed from https://api.lemonsqueezy.com/v1/. All requests should be made over HTTPS and every request requires authentication.

The API is based on the JSON:API spec and as such you are required to add the following headers in each request.

Accept: application/vnd.api+json
Content-Type: application/vnd.api+json

Authentication

The API uses Bearer authentication for all requests. This would be the API key that you previously created in step 1.

To authenticate, add an Authorization header to all requests containing a valid API key:

Authorization: Bearer {api_key}

In total, you need three headers when making requests to our API:

  • Accept
  • Content-Type
  • Authorization

API overview

The Lemon Squeezy API covers all data types used in your store such as Products, Customers, Discounts and Files.

You can use the API to manage your store as well as set up payments for customers, access prior orders and manage ongoing subscriptions and software license keys.

Some examples of what’s possible with the API:

  • Show what you’re selling inside your app
  • Create checkout links to sign up new subscribers
  • Create custom-priced checkouts for certain customers
  • Access customer details and a list of their previous orders
  • Create discount codes on-the-fly
  • Activate and validate license keys
  • Upgrade, downgrade, cancel, resume, pause and un-pause subscriptions

As per the JSON:API spec, responses will contain object data along with references to all relationships and optional “included” data.

For example:

{
  "jsonapi": {
    "version": "1.0"
  },
  "links": {
    "self": "https://api.lemonsqueezy.com/v1/orders/1"
  },
  "data": {
    "type": "orders",
    "id": "1",
    "attributes": {
      "store_id": 1,
      "customer_id": 1,
      "identifier": "104e18a2-d755-4d4b-80c4-a6c1dcbe1c10",
      "order_number": 1,
      "user_name": "John Doe",
      "user_email": "[email protected]",
      "currency": "USD",
      "currency_rate": "1.0000",
      "subtotal": 999,
      "discount_total": 0,
      "tax": 200,
      "total": 1199,
      "subtotal_usd": 999,
      "discount_total_usd": 0,
      "tax_usd": 200,
      "total_usd": 1199,
      "tax_name": "VAT",
      "tax_rate": "20.00",
      "status": "paid",
      "status_formatted": "Paid",
      "refunded": false,
      "refunded_at": null,
      "subtotal_formatted": "$9.99",
      "discount_total_formatted": "$0.00",
      "tax_formatted": "$2.00",
      "total_formatted": "$11.99",
      "first_order_item": {
        "id": 1,
        "order_id": 1,
        "product_id": 1,
        "variant_id": 1,
        "product_name": "Lemonade - 2 years",
        "variant_name": "Default",
        "price": 1199,
        "created_at": "2021-08-17T09:45:53.000000Z",
        "updated_at": "2021-08-17T09:45:53.000000Z",
        "deleted_at": null,
        "test_mode": false
      },
      "urls": {
        "receipt": "https://app.lemonsqueezy.com/my-orders/104e18a2-d755-4d4b-80c4-a6c1dcbe1c10?signature=8847fff02e1bfb0c7c43ff1cdf1b1657a8eed2029413692663b86859208c9f42"
      },
      "created_at": "2021-08-17T09:45:53.000000Z",
      "updated_at": "2021-08-17T09:45:53.000000Z"
    },
    "relationships": {
      "store": {
        "links": {
          "related": "https://api.lemonsqueezy.com/v1/orders/1/store",
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/store"
        }
      },
      "customer": {
        "links": {
          "related": "https://api.lemonsqueezy.com/v1/subscriptions/1/customer",
          "self": "https://api.lemonsqueezy.com/v1/subscriptions/1/relationships/customer"
        }
      },
      "order-items": {
        "links": {
          "related": "https://api.lemonsqueezy.com/v1/orders/1/order-items",
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/order-items"
        }
      },
      "subscriptions": {
        "links": {
          "related": "https://api.lemonsqueezy.com/v1/orders/1/subscriptions",
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/subscriptions"
        }
      },
      "license-keys": {
        "links": {
          "related": "https://api.lemonsqueezy.com/v1/orders/1/license-keys",
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/license-keys"
        }
      },
      "discount-redemptions": {
        "links": {
          "related": "https://api.lemonsqueezy.com/v1/orders/1/discount-redemptions",
          "self": "https://api.lemonsqueezy.com/v1/orders/1/relationships/discount-redemptions"
        }
      }
    },
    "links": {
      "self": "https://api.lemonsqueezy.com/v1/orders/1"
    }
  }
}

Webhooks allow you to keep your app data up-to-date with Lemon Squeezy by sending real-time notifications when important events happen in Lemon Squeezy.


Was this page helpful?