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

# Create Referral Code

> Create or fetch a referral code for a customer in a referral program.

### Body Parameters

The unique identifier of the customer

ID of your referral program

### Response

The referral code that can be shared with customers

Your unique identifier for the customer

The timestamp of when the referral code was created

```json 200 theme={null}
{
  "code": "<string>",
  "customer_id": "<string>",
  "created_at": 123
}
```


## OpenAPI

````yaml openapi POST /v1/referrals.create_code
openapi: 3.1.0
info:
  title: Autumn API
  version: 2.6.0
servers:
  - url: https://api.useautumn.com
    description: Production server
security:
  - secretKey: []
paths:
  /v1/referrals.create_code:
    post:
      tags:
        - referrals
      description: Create or fetch a referral code for a customer in a referral program.
      operationId: createReferralCode
      parameters:
        - name: x-api-version
          in: header
          required: true
          schema:
            type: string
            default: 2.6.0
          x-speakeasy-globals-hidden: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                customer_id:
                  type: string
                  description: The unique identifier of the customer
                program_id:
                  type: string
                  description: ID of your referral program
              required:
                - customer_id
                - program_id
              title: CreateReferralCodeParams
              examples:
                - customer_id: cus_123
                  program_id: prog_123
            example:
              customer_id: cus_123
              program_id: prog_123
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  code:
                    type: string
                    description: The referral code that can be shared with customers
                  customer_id:
                    type: string
                    description: Your unique identifier for the customer
                  created_at:
                    type: number
                    description: The timestamp of when the referral code was created
                required:
                  - code
                  - customer_id
                  - created_at
                examples:
                  - code: <string>
                    customer_id: <string>
                    created_at: 123
              example:
                code: <string>
                customer_id: <string>
                created_at: 123
      x-codeSamples:
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Autumn } from 'autumn-js'

            const autumn = new Autumn()

            const result = await autumn.referrals.createCode({
              customerId: "cus_123",
              programId: "prog_123",
            });
        - lang: python
          label: Python (SDK)
          source: |-
            from autumn_sdk import Autumn

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

            res = autumn.referrals.create_code(
                customer_id="cus_123",
                program_id="prog_123",
            )
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.