> ## Documentation Index
> Fetch the complete documentation index at: https://docs.useautumn.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Search Request Logs

> Search API requests and incoming Stripe webhooks for your organization and environment.

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>;
};

Search API requests and incoming Stripe webhooks for your organization and environment.

### Common Use Cases

<CodeGroup>
  ```typescript Customer errors theme={null}
  const logs = await autumn.logs.search({
      query: "where customer_id == 'cus_123' and status_code >= 400",
      limit: 50,
  });
  ```

  ```typescript Feature requests theme={null}
  const logs = await autumn.logs.search({
      query: "where request_body.feature_id == 'credits' | order by timestamp desc",
      range: {
          startDate: new Date(Date.now() - 60 * 60 * 1000).toISOString(),
      },
  });
  ```

  ```typescript Stripe webhooks theme={null}
  const logs = await autumn.logs.search({
      query: "where source == 'stripe_webhook' and stripe_event_type == 'customer.subscription.updated'",
      limit: 25,
  });
  ```
</CodeGroup>

### Writing a query

Use `where` to filter, `order by` to sort, and `limit` to cap results. Join these steps with `|`. Without a query, you get the most recent logs.

Filter on fields like `customer_id`, `status_code`, `request_path`, and `stripe_event_type`. Use dot paths for body fields, such as `request_body.feature_id`, or `contains` to find text: `where response_body contains 'error'`.

Field names inside the query stay in snake\_case, including when you use the TypeScript SDK.

By default, the search covers the last 30 minutes. Set `range` to search another window of up to 7 days.

### Body Parameters

<DynamicParamField body="query" type="string">
  Filter and sort logs using where, order by, and limit, joined with |. Omit to return recent logs.
</DynamicParamField>

<DynamicParamField body="range" type="object">
  Time window to search. Defaults to the last 30 minutes. Maximum 7 days.

  <Expandable title="properties">
    <DynamicParamField body="start_date" type="string">
      Start of the time window in ISO 8601 format. Defaults to 30 minutes before end\_date.
    </DynamicParamField>

    <DynamicParamField body="end_date" type="string">
      End of the time window in ISO 8601 format. Defaults to now.
    </DynamicParamField>
  </Expandable>
</DynamicParamField>

<DynamicParamField body="limit" type="integer">
  Maximum number of logs to return, from 1 to 200. Defaults to 100.
</DynamicParamField>

### Response

<DynamicResponseField name="list" type="object[]">
  Matching logs, newest first unless you specify an order.

  <Expandable title="properties">
    <DynamicResponseField name="timestamp" type="string">
      When the log was recorded, in ISO 8601 format.
    </DynamicResponseField>

    <DynamicResponseField name="source" type="'api_request' | 'stripe_webhook'">
      Whether this was an API request or an incoming Stripe webhook.
    </DynamicResponseField>

    <DynamicResponseField name="status_code" type="number">
      HTTP response status code.
    </DynamicResponseField>

    <DynamicResponseField name="request" type="object">
      HTTP request details.

      <Expandable title="properties">
        <DynamicResponseField name="method" type="string | null">
          HTTP method, such as GET or POST.
        </DynamicResponseField>

        <DynamicResponseField name="url" type="string | null">
          Full request URL.
        </DynamicResponseField>

        <DynamicResponseField name="path" type="string | null">
          Request path without the host or query string.
        </DynamicResponseField>
      </Expandable>
    </DynamicResponseField>

    <DynamicResponseField name="context" type="object">
      Organization, customer, and user associated with the request.

      <Expandable title="properties">
        <DynamicResponseField name="org_id" type="string | null">
          Autumn organization that made the request.
        </DynamicResponseField>

        <DynamicResponseField name="customer_id" type="string | null">
          Customer ID associated with the request, if available.
        </DynamicResponseField>

        <DynamicResponseField name="entity_id" type="string | null">
          Entity ID associated with the request, if available.
        </DynamicResponseField>

        <DynamicResponseField name="auth_type" type="string | null">
          How the request was authenticated, such as secret\_key or dashboard.
        </DynamicResponseField>

        <DynamicResponseField name="user_id" type="string | null">
          Authenticated user's ID, if available.
        </DynamicResponseField>

        <DynamicResponseField name="user_email" type="string | null">
          Authenticated user's email, if available.
        </DynamicResponseField>
      </Expandable>
    </DynamicResponseField>

    <DynamicResponseField name="stripe" type="object">
      Stripe webhook details. Fields are null for API requests.

      <Expandable title="properties">
        <DynamicResponseField name="event_id" type="string | null">
          Stripe event ID, if this was a Stripe webhook.
        </DynamicResponseField>

        <DynamicResponseField name="event_type" type="string | null">
          Stripe event type, such as customer.subscription.updated.
        </DynamicResponseField>

        <DynamicResponseField name="object_id" type="string | null">
          ID of the Stripe object the event refers to.
        </DynamicResponseField>
      </Expandable>
    </DynamicResponseField>

    <DynamicResponseField name="request_body" type="any | null">
      Recorded request body, or null if unavailable.
    </DynamicResponseField>

    <DynamicResponseField name="response_body" type="any | null">
      Recorded response body, or null if unavailable.
    </DynamicResponseField>
  </Expandable>
</DynamicResponseField>

<ResponseExample>
  ```json 200 theme={null}
  {
    "list": [
      {
        "timestamp": "2026-09-21T12:00:00.000Z",
        "source": "api_request",
        "status_code": 200,
        "request": {
          "method": "POST",
          "url": "https://api.useautumn.com/v1/balances.check",
          "path": "/v1/balances.check"
        },
        "context": {
          "org_id": "org_123",
          "customer_id": "cus_123",
          "entity_id": null,
          "auth_type": "secret_key",
          "user_id": "user_123",
          "user_email": "user@example.com"
        },
        "stripe": {
          "event_id": null,
          "event_type": null,
          "object_id": null
        },
        "request_body": {
          "customer_id": "cus_123"
        },
        "response_body": {
          "allowed": true
        }
      }
    ]
  }
  ```
</ResponseExample>


## OpenAPI

````yaml openapi POST /v1/logs.search
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/logs.search:
    post:
      tags:
        - logs
      description: >-
        Search API requests and incoming Stripe webhooks for your organization
        and environment.
      operationId: searchRequestLogs
      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:
                query:
                  type: string
                  maxLength: 4000
                  description: >-
                    Filter and sort logs using where, order by, and limit,
                    joined with |. Omit to return recent logs.
                range:
                  type: object
                  properties:
                    start_date:
                      type: string
                      description: >-
                        Start of the time window in ISO 8601 format. Defaults to
                        30 minutes before end_date.
                    end_date:
                      type: string
                      description: >-
                        End of the time window in ISO 8601 format. Defaults to
                        now.
                  additionalProperties: false
                  title: SearchLogsRange
                  description: >-
                    Time window to search. Defaults to the last 30 minutes.
                    Maximum 7 days.
                limit:
                  type: integer
                  minimum: 1
                  maximum: 200
                  description: >-
                    Maximum number of logs to return, from 1 to 200. Defaults to
                    100.
              additionalProperties: false
              title: SearchRequestLogsParams
              examples:
                - query: where status_code >= 400 | order by timestamp desc
                  limit: 50
            example:
              query: where status_code >= 400 | order by timestamp desc
              limit: 50
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  list:
                    type: array
                    items:
                      type: object
                      properties:
                        timestamp:
                          type: string
                          description: When the log was recorded, in ISO 8601 format.
                        source:
                          enum:
                            - api_request
                            - stripe_webhook
                          type: string
                          description: >-
                            Whether this was an API request or an incoming
                            Stripe webhook.
                        status_code:
                          type: number
                          description: HTTP response status code.
                        request:
                          type: object
                          properties:
                            method:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: HTTP method, such as GET or POST.
                            url:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: Full request URL.
                            path:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: Request path without the host or query string.
                          required:
                            - method
                            - url
                            - path
                          description: HTTP request details.
                        context:
                          type: object
                          properties:
                            org_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: Autumn organization that made the request.
                            customer_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: >-
                                Customer ID associated with the request, if
                                available.
                            entity_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: >-
                                Entity ID associated with the request, if
                                available.
                            auth_type:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: >-
                                How the request was authenticated, such as
                                secret_key or dashboard.
                            user_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: Authenticated user's ID, if available.
                            user_email:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: Authenticated user's email, if available.
                          required:
                            - org_id
                            - customer_id
                            - entity_id
                            - auth_type
                            - user_id
                            - user_email
                          description: >-
                            Organization, customer, and user associated with the
                            request.
                        stripe:
                          type: object
                          properties:
                            event_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: Stripe event ID, if this was a Stripe webhook.
                            event_type:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: >-
                                Stripe event type, such as
                                customer.subscription.updated.
                            object_id:
                              anyOf:
                                - type: string
                                - type: 'null'
                              description: ID of the Stripe object the event refers to.
                          required:
                            - event_id
                            - event_type
                            - object_id
                          description: >-
                            Stripe webhook details. Fields are null for API
                            requests.
                        request_body:
                          anyOf:
                            - {}
                            - type: 'null'
                          description: Recorded request body, or null if unavailable.
                        response_body:
                          anyOf:
                            - {}
                            - type: 'null'
                          description: Recorded response body, or null if unavailable.
                      required:
                        - timestamp
                        - source
                        - status_code
                        - request
                        - context
                        - stripe
                    description: Matching logs, newest first unless you specify an order.
                required:
                  - list
                examples:
                  - list:
                      - timestamp: '2026-09-21T12:00:00.000Z'
                        source: api_request
                        status_code: 200
                        request:
                          method: POST
                          url: https://api.useautumn.com/v1/balances.check
                          path: /v1/balances.check
                        context:
                          org_id: org_123
                          customer_id: cus_123
                          entity_id: null
                          auth_type: secret_key
                          user_id: user_123
                          user_email: user@example.com
                        stripe:
                          event_id: null
                          event_type: null
                          object_id: null
                        request_body:
                          customer_id: cus_123
                        response_body:
                          allowed: true
              example:
                list:
                  - timestamp: '2026-09-21T12:00:00.000Z'
                    source: api_request
                    status_code: 200
                    request:
                      method: POST
                      url: https://api.useautumn.com/v1/balances.check
                      path: /v1/balances.check
                    context:
                      org_id: org_123
                      customer_id: cus_123
                      entity_id: null
                      auth_type: secret_key
                      user_id: user_123
                      user_email: user@example.com
                    stripe:
                      event_id: null
                      event_type: null
                      object_id: null
                    request_body:
                      customer_id: cus_123
                    response_body:
                      allowed: true
      x-codeSamples:
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Autumn } from 'autumn-js'

            const autumn = new Autumn()

            const result = await autumn.logs.search({
              query: "where status_code >= 400 | order by timestamp desc",
              limit: 50,
            });
        - lang: python
          label: Python (SDK)
          source: |-
            from autumn_sdk import Autumn

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

            res = autumn.logs.search(
                query="where status_code >= 400 | order by timestamp desc",
                limit=50,
            )
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````