> ## Documentation Index
> Fetch the complete documentation index at: https://autumn-b9b4c0fb-dev.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# List Purchases

> Lists one-off plan purchases across customers, live or expired. Filter by customer, entity, plan, or status. Pages may hold fewer than `limit` rows while `has_more` is true.

export const DynamicResponseExample = ({json, statusCode = "200"}) => {
  const toCamelCase = str => {
    return str.replace(/_([a-z])/g, (_, c) => c.toUpperCase());
  };
  const convertKeysToCamelCase = obj => {
    if (Array.isArray(obj)) {
      return obj.map(item => convertKeysToCamelCase(item));
    }
    if (obj !== null && typeof obj === "object") {
      return Object.keys(obj).reduce((acc, key) => {
        const camelKey = toCamelCase(key);
        acc[camelKey] = convertKeysToCamelCase(obj[key]);
        return acc;
      }, {});
    }
    return obj;
  };
  const [isTypeScript, setIsTypeScript] = useState(() => {
    if (typeof window !== "undefined") {
      try {
        const lang = localStorage.getItem("code");
        return JSON.parse(lang) === "typescript";
      } catch {
        return true;
      }
    }
    return true;
  });
  useEffect(() => {
    const onMintlifyStorage = event => {
      if (event.detail?.key === "code") {
        try {
          const value = JSON.parse(event.detail.value);
          setIsTypeScript(value === "typescript");
        } catch {}
      }
    };
    const pollInterval = setInterval(() => {
      try {
        const lang = localStorage.getItem("code");
        const value = JSON.parse(lang);
        setIsTypeScript(value === "typescript");
      } catch {}
    }, 300);
    document.addEventListener("mintlify-localstorage", onMintlifyStorage);
    return () => {
      document.removeEventListener("mintlify-localstorage", onMintlifyStorage);
      clearInterval(pollInterval);
    };
  }, []);
  const camelCaseJson = useMemo(() => convertKeysToCamelCase(json), [json]);
  const snakeCaseString = JSON.stringify(json, null, 2);
  const camelCaseString = JSON.stringify(camelCaseJson, null, 2);
  return <ResponseExample>
			{isTypeScript ? <CodeBlock language="json" filename={statusCode}>
					{camelCaseString}
				</CodeBlock> : <CodeBlock language="json" filename={statusCode}>
					{snakeCaseString}
				</CodeBlock>}
		</ResponseExample>;
};

export const DynamicResponseField = ({children, name, ...props}) => {
  const convertToCamelCase = str => {
    if (typeof str !== "string") return str;
    return str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase());
  };
  const [lang, setLang] = useState(() => {
    if (typeof window !== "undefined") {
      const stored = localStorage.getItem("code");
      return stored || '"typescript"';
    }
    return '"typescript"';
  });
  useEffect(() => {
    const onMintlifyStorage = event => {
      const key = event.detail?.key;
      if (key === "code") {
        setLang(event.detail.value);
      }
    };
    const pollInterval = setInterval(() => {
      const current = localStorage.getItem("code");
      if (current && current !== lang) {
        setLang(current);
      }
    }, 500);
    document.addEventListener("mintlify-localstorage", onMintlifyStorage);
    return () => {
      document.removeEventListener("mintlify-localstorage", onMintlifyStorage);
      clearInterval(pollInterval);
    };
  }, [lang]);
  const resolvedName = useMemo(() => {
    try {
      const value = JSON.parse(lang);
      const useCamelCase = value === "typescript";
      return useCamelCase ? convertToCamelCase(name) : name;
    } catch {
      return name;
    }
  }, [name, lang]);
  return <ResponseField name={resolvedName} {...props}>
			{children}
		</ResponseField>;
};

export const DynamicParamField = ({children, body, path, ...props}) => {
  const convertToCamelCase = str => {
    if (typeof str !== "string") return str;
    return str.replace(/[_-](\w)/g, (_, c) => c.toUpperCase());
  };
  const [lang, setLang] = useState(() => {
    if (typeof window !== "undefined") {
      const stored = localStorage.getItem("code");
      return stored || '"typescript"';
    }
    return '"typescript"';
  });
  useEffect(() => {
    const onMintlifyStorage = event => {
      const key = event.detail?.key;
      if (key === "code") {
        setLang(event.detail.value);
      }
    };
    const pollInterval = setInterval(() => {
      const current = localStorage.getItem("code");
      if (current && current !== lang) {
        setLang(current);
      }
    }, 500);
    document.addEventListener("mintlify-localstorage", onMintlifyStorage);
    return () => {
      document.removeEventListener("mintlify-localstorage", onMintlifyStorage);
      clearInterval(pollInterval);
    };
  }, [lang]);
  const resolvedBody = useMemo(() => {
    try {
      const value = JSON.parse(lang);
      const useCamelCase = value === "typescript";
      return useCamelCase ? convertToCamelCase(body) : body;
    } catch {
      return body;
    }
  }, [body, lang]);
  const resolvedPath = useMemo(() => {
    try {
      const value = JSON.parse(lang);
      const useCamelCase = value === "typescript";
      return useCamelCase ? convertToCamelCase(path) : path;
    } catch {
      return path;
    }
  }, [path, lang]);
  return <ParamField body={resolvedBody} path={resolvedPath} {...props}>
			{children}
		</ParamField>;
};

Lists one-off plan purchases. By default only live purchases are returned; pass `statuses: ["expired"]` to see purchases that have ended.

<Note>
  A page can hold fewer than `limit` rows (even zero) while `has_more` is `true`. Keep paginating until `has_more` is `false`.
</Note>

### Body Parameters

<DynamicParamField body="customer_id" type="string">
  Only return rows for this customer. Omit to list across every customer.
</DynamicParamField>

<DynamicParamField body="entity_id" type="string">
  Only return rows for this entity. Requires customer\_id.
</DynamicParamField>

<DynamicParamField body="limit" type="integer">
  Number of items to return. Default 50, hard ceiling 200.
</DynamicParamField>

<DynamicParamField body="start_cursor" type="string">
  Opaque pagination cursor. Empty string (default) requests the first page; use next\_cursor from a prior response for subsequent pages.
</DynamicParamField>

<DynamicParamField body="statuses" type="('active' | 'scheduled' | 'past_due' | 'expired')[]">
  Statuses to include. Defaults to active and scheduled. past\_due matches plans with overdue payments, which read as status active with past\_due true.
</DynamicParamField>

<DynamicParamField body="plan_id" type="string">
  Only return rows for this plan.
</DynamicParamField>

### Response

<DynamicResponseField name="list" type="object[]">
  Rows on this page.

  <Expandable title="properties">
    <DynamicResponseField name="plan_id" type="string">
      The unique identifier of the purchased plan.
    </DynamicResponseField>

    <DynamicResponseField name="expires_at" type="number | null">
      Timestamp when the purchase expires, or null for lifetime access.
    </DynamicResponseField>

    <DynamicResponseField name="started_at" type="number">
      Timestamp when the purchase was made.
    </DynamicResponseField>

    <DynamicResponseField name="quantity" type="number">
      Number of units purchased.
    </DynamicResponseField>

    <DynamicResponseField name="scope" type="'customer' | 'entity'">
      Whether this purchase is attached at the customer level or entity level.
    </DynamicResponseField>

    <DynamicResponseField name="id" type="string">
      The unique identifier of this purchase. Falls back to the internal ID when none was provided.
    </DynamicResponseField>

    <DynamicResponseField name="status" type="'active' | 'scheduled' | 'expired'">
      Current status of the purchase.
    </DynamicResponseField>

    <DynamicResponseField name="customer_id" type="string">
      The customer this row belongs to.
    </DynamicResponseField>

    <DynamicResponseField name="entity_id" type="string | null">
      The entity this row is scoped to, or null.
    </DynamicResponseField>

    <DynamicResponseField name="created_at" type="number">
      Timestamp when this row was created.
    </DynamicResponseField>
  </Expandable>
</DynamicResponseField>

<DynamicResponseField name="has_more" type="boolean">
  Whether more results exist. A page may hold fewer than `limit` items (even zero) while `has_more` is true, so paginate until `has_more` is false.
</DynamicResponseField>

<DynamicResponseField name="next_cursor" type="string | null">
  Pass as start\_cursor to fetch the next page. Null when has\_more is false.
</DynamicResponseField>

<ResponseExample>
  ```json 200 theme={null}
  {
    "list": [
      {
        "id": "cus_prod_123",
        "plan_id": "credit_pack",
        "status": "expired",
        "expires_at": null,
        "started_at": 1768817161016,
        "quantity": 1,
        "scope": "customer",
        "customer_id": "cus_123",
        "entity_id": null,
        "created_at": 1768817161016
      }
    ],
    "has_more": false,
    "next_cursor": null
  }
  ```
</ResponseExample>


## OpenAPI

````yaml openapi POST /v1/purchases.list
openapi: 3.1.0
info:
  title: Autumn API
  version: 2.4.0
servers:
  - url: https://api.useautumn.com
    description: Production server
security:
  - secretKey: []
paths:
  /v1/purchases.list:
    post:
      tags:
        - customers
      description: >-
        Lists one-off plan purchases across customers, live or expired. Filter
        by customer, entity, plan, or status. Pages may hold fewer than `limit`
        rows while `has_more` is true.
      operationId: listPurchases
      parameters:
        - name: x-api-version
          in: header
          required: true
          schema:
            type: string
            default: 2.4.0
          x-speakeasy-globals-hidden: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                customer_id:
                  type: string
                  description: >-
                    Only return rows for this customer. Omit to list across
                    every customer.
                entity_id:
                  type: string
                  description: Only return rows for this entity. Requires customer_id.
                limit:
                  type: integer
                  minimum: 1
                  maximum: 200
                  default: 50
                  description: Number of items to return. Default 50, hard ceiling 200.
                start_cursor:
                  type: string
                  default: ''
                  description: >-
                    Opaque pagination cursor. Empty string (default) requests
                    the first page; use next_cursor from a prior response for
                    subsequent pages.
                statuses:
                  type: array
                  minItems: 1
                  items:
                    enum:
                      - active
                      - scheduled
                      - past_due
                      - expired
                    type: string
                  description: >-
                    Statuses to include. Defaults to active and scheduled.
                    past_due matches plans with overdue payments, which read as
                    status active with past_due true.
                plan_id:
                  type: string
                  description: Only return rows for this plan.
              title: ListPurchasesParams
              examples:
                - customer_id: cus_123
                  statuses:
                    - active
                    - expired
            example:
              customer_id: cus_123
              statuses:
                - active
                - expired
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  list:
                    type: array
                    items:
                      type: object
                      properties:
                        plan_id:
                          type: string
                          description: The unique identifier of the purchased plan.
                        expires_at:
                          anyOf:
                            - type: number
                            - type: 'null'
                          description: >-
                            Timestamp when the purchase expires, or null for
                            lifetime access.
                        started_at:
                          type: number
                          description: Timestamp when the purchase was made.
                        quantity:
                          type: number
                          description: Number of units purchased.
                        scope:
                          enum:
                            - customer
                            - entity
                          type: string
                          description: >-
                            Whether this purchase is attached at the customer
                            level or entity level.
                        id:
                          type: string
                          description: >-
                            The unique identifier of this purchase. Falls back
                            to the internal ID when none was provided.
                        status:
                          enum:
                            - active
                            - scheduled
                            - expired
                          type: string
                          description: Current status of the purchase.
                        customer_id:
                          type: string
                          description: The customer this row belongs to.
                        entity_id:
                          anyOf:
                            - type: string
                            - type: 'null'
                          description: The entity this row is scoped to, or null.
                        created_at:
                          type: number
                          description: Timestamp when this row was created.
                      required:
                        - plan_id
                        - expires_at
                        - started_at
                        - quantity
                        - id
                        - status
                        - customer_id
                        - entity_id
                        - created_at
                    description: Rows on this page.
                  has_more:
                    type: boolean
                    description: >-
                      Whether more results exist. A page may hold fewer than
                      `limit` items (even zero) while `has_more` is true, so
                      paginate until `has_more` is false.
                  next_cursor:
                    anyOf:
                      - type: string
                      - type: 'null'
                    description: >-
                      Pass as start_cursor to fetch the next page. Null when
                      has_more is false.
                required:
                  - list
                  - has_more
                  - next_cursor
                examples:
                  - list:
                      - id: cus_prod_123
                        plan_id: credit_pack
                        status: expired
                        expires_at: null
                        started_at: 1768817161016
                        quantity: 1
                        scope: customer
                        customer_id: cus_123
                        entity_id: null
                        created_at: 1768817161016
                    has_more: false
                    next_cursor: null
              example:
                list:
                  - id: cus_prod_123
                    plan_id: credit_pack
                    status: expired
                    expires_at: null
                    started_at: 1768817161016
                    quantity: 1
                    scope: customer
                    customer_id: cus_123
                    entity_id: null
                    created_at: 1768817161016
                has_more: false
                next_cursor: null
      x-codeSamples:
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Autumn } from 'autumn-js'

            const autumn = new Autumn()

            const result = await autumn.customers.listPurchases({
              customerId: "cus_123",
              statuses: [
                "active",
                "expired",
              ],
            });
        - lang: python
          label: Python (SDK)
          source: |-
            from autumn_sdk import Autumn

            autumn = Autumn(secret_key="am_sk_test...")

            res = autumn.customers.list_purchases(
                customer_id="cus_123",
                limit=50,
                start_cursor="",
                statuses=[
                    "active",
                    "expired",
                ],
            )
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````