> ## 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.

# Generate Stripe OAuth URL

> Generates a Stripe Connect OAuth URL for a platform organization. Use this to allow your tenants to connect their Stripe accounts.

<Info>
  Generates a Stripe Connect OAuth URL for a platform organization. Use this to allow your tenants to connect their Stripe accounts through the OAuth flow.
</Info>

## OAuth Flow

After generating the OAuth URL:

1. Redirect your tenant to the `oauth_url`
2. User authorizes their Stripe account
3. Stripe redirects to Autumn's callback URL
4. Autumn processes the authorization and redirects to your `redirect_url`
5. Your `redirect_url` will receive query parameters:
   * `success=true` or `success=false`
   * `message=...` (if error occurred)

<Note>
  OAuth state is stored in Upstash with a 10-minute expiry. The organization must have been created via the platform API before generating an OAuth URL.
</Note>


## OpenAPI

````yaml platform POST /platform/oauth_url
openapi: 3.0.0
info:
  title: Platform API (Beta)
  version: 1.0.0
  description: >
    **Private Preview** - Contact hey@useautumn.com to get access.


    The Platform API allows you to manage organizations and Stripe Connect
    accounts on behalf of your tenants. All endpoints require platform feature
    access.
servers:
  - url: https://api.useautumn.com/v1
security:
  - bearerAuth: []
paths:
  /platform/oauth_url:
    post:
      summary: Generate Stripe OAuth URL
      description: >-
        Generates a Stripe Connect OAuth URL for a platform organization. Use
        this to allow your tenants to connect their Stripe accounts.
      operationId: generateOAuthURL
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/GenerateOAuthURLRequest'
      responses:
        '200':
          description: OAuth URL generated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GenerateOAuthURLResponse'
        '400':
          description: Invalid request parameters
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '404':
          description: Organization not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
      security:
        - bearerAuth: []
      x-code-samples:
        - lang: curl
          source: |
            curl -X POST 'https://api.useautumn.com/v1/platform/oauth_url' \
            -H 'Authorization: Bearer am_sk_test_...' \
            -H 'Content-Type: application/json' \
            -d '{
              "organization_slug": "tenant-org",
              "env": "test",
              "redirect_url": "https://yourapp.com/stripe/callback"
            }'
components:
  schemas:
    GenerateOAuthURLRequest:
      type: object
      required:
        - organization_slug
        - env
        - redirect_url
      properties:
        organization_slug:
          type: string
          description: The slug of the organization.
        env:
          type: string
          enum:
            - test
            - live
          description: 'Environment: ''test'' or ''live''.'
        redirect_url:
          type: string
          format: uri
          description: URL to redirect to after OAuth completion.
    GenerateOAuthURLResponse:
      type: object
      properties:
        oauth_url:
          type: string
          format: uri
          description: Stripe Connect OAuth URL to redirect the user to.
    ErrorResponse:
      type: object
      properties:
        message:
          type: string
          description: Error description.
        code:
          type: string
          description: Error code.
          enum:
            - not_found
            - forbidden
            - invalid_input
            - internal_error
            - not_allowed
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Autumn API key with Bearer prefix

````