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

# List a customer's referrals

> A customer's referral codes, who they referred, and who referred them.

Lists the customer's referral codes, each customer they referred (`asReferrer`, newest first) with its `status` (`pending`, `rewarded` or `refused`) and `refusedReason`, and who referred them (`asReferee`). A promotion code the customer redeemed isn't a referral, so it isn't listed here; see [List a customer's redemptions](https://docs.integrateledger.com/api-reference/customers/redemptions.md). Needs the **Customers** permission at Read.


## OpenAPI

````yaml openapi.json GET /v1/customers/referrals
openapi: 3.1.0
info:
  title: Ledger API
  version: 0.1.0
servers:
  - url: https://api.integrateledger.com
    description: Hosted Ledger API
security: []
paths:
  /v1/customers/referrals:
    get:
      tags:
        - Customers
      summary: List a customer's referrals
      operationId: listCustomerReferrals
      parameters:
        - schema:
            type: string
            minLength: 1
            maxLength: 255
            description: Your ID for the customer.
          required: true
          description: Your ID for the customer.
          name: customerId
          in: query
      responses:
        '200':
          description: >-
            The customer's referral codes, the customers they referred, and who
            referred them. A promotion code they redeemed isn't a referral, so
            it isn't here.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomerReferrals'
        '400':
          description: Invalid request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RewardError'
        '401':
          description: Invalid Ledger API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RewardError'
        '403':
          $ref: '#/components/responses/InsufficientPermissions'
        '404':
          description: >-
            No such program (`referral_program_not_found`) or customer
            (`customer_not_found`)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RewardError'
        '429':
          $ref: '#/components/responses/RateLimited'
      security:
        - ApiKey: []
      x-codeSamples:
        - lang: python
          label: Python SDK
          source: |-
            import os
            from integrateledger import ledger

            client = ledger(api_key=os.environ["LEDGER_API_KEY"])
            client.list_customer_referrals(customer_id="user_123")
        - lang: bash
          label: cURL
          source: >-
            curl --request GET
            'https://api.integrateledger.com/v1/customers/referrals?customerId=user_123'
            \
              -H "Authorization: Bearer $LEDGER_API_KEY"
        - lang: typescript
          label: TypeScript SDK
          source: >-
            import ledger from "integrateledger";


            const client = new ledger({ apiKey: process.env.LEDGER_API_KEY ?? ""
            });

            await client.listCustomerReferrals({ customerId: "user_123" });
components:
  schemas:
    CustomerReferrals:
      type: object
      properties:
        codes:
          type: array
          items:
            $ref: '#/components/schemas/ReferralCode'
        asReferrer:
          type: array
          items:
            $ref: '#/components/schemas/Referral'
          description: The customers this one referred, newest first.
        asReferee:
          allOf:
            - $ref: '#/components/schemas/Referral'
            - description: >-
                Who referred this customer, if anyone (their most recent
                referral).
      required:
        - codes
        - asReferrer
        - asReferee
    RewardError:
      type: object
      properties:
        error:
          type: string
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        issues:
          type: array
          items:
            type: object
            properties:
              path:
                type: string
              message:
                type: string
            required:
              - path
              - message
          description: >-
            With `invalid_request`: each field that failed validation and why.
            `path` is empty for the body itself, such as an unknown field.
      required:
        - error
    ReferralCode:
      type: object
      properties:
        code:
          type: string
          description: >-
            8 characters from A-Z and 2-9, without 0, O, 1, I or L. The same
            code on every call.
        programId:
          type: string
        customerId:
          type: string
        createdAt:
          type: string
      required:
        - code
        - programId
        - customerId
        - createdAt
    Referral:
      type:
        - object
        - 'null'
      properties:
        referralId:
          type: integer
        programId:
          type: string
        referrerId:
          type: string
        refereeId:
          type: string
        status:
          type: string
          enum:
            - pending
            - rewarded
            - refused
          description: >-
            pending: waiting for the trigger (the referee's first paid invoice).
            rewarded: the referrer got their reward. refused: see
            `refusedReason`; a referee keeps their own reward.
        refusedReason:
          type:
            - string
            - 'null'
          enum:
            - same_payment_method
            - referrer_limit_reached
            - null
          description: >-
            `same_payment_method`: the referee paid with a card the referrer has
            saved. `referrer_limit_reached`: the referrer had the program's most
            rewards already.
        rewardedAt:
          type:
            - string
            - 'null'
        createdAt:
          type: string
      required:
        - referralId
        - programId
        - referrerId
        - refereeId
        - status
        - refusedReason
        - rewardedAt
        - createdAt
      description: >-
        The referral, when the code was a referrer's: `rewarded` at once for a
        `signup` program, `pending` until the referee's first payment for
        `first_payment`. Null for a promotion code.
    InsufficientPermissionsError:
      type: object
      properties:
        error:
          type: string
          example: insufficient_permissions
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
        requiredScope:
          type: string
          example: customers:read
      required:
        - error
        - requiredScope
    RateLimitError:
      type: object
      properties:
        error:
          type: string
          example: rate_limited
        message:
          type: string
          description: >-
            What went wrong and what to do about it, for a person or an agent to
            read. Every Ledger error has one. The wording can change: branch on
            `error`, not on this text.
          example: >-
            No customer "user_123" exists in this environment. Create it with
            POST /v1/customers, or check that the API key is for the right
            environment.
      required:
        - error
  responses:
    InsufficientPermissions:
      description: >-
        The API key works but lacks the permission this endpoint needs, named in
        requiredScope. See the API keys guide.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/InsufficientPermissionsError'
    RateLimited:
      description: >-
        Too many requests. Wait Retry-After seconds, then retry. See the rate
        limits guide.
      headers:
        Retry-After:
          description: Seconds until a request is allowed again
          schema:
            type: integer
        RateLimit-Limit:
          description: 'The burst: requests allowed at once'
          schema:
            type: integer
        RateLimit-Remaining:
          description: Requests left right now
          schema:
            type: integer
        RateLimit-Reset:
          description: Seconds until the full burst is back
          schema:
            type: integer
        RateLimit-Policy:
          description: >-
            The sustained rate per second and the burst, such as
            200;w=1;burst=1000
          schema:
            type: string
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/RateLimitError'
  securitySchemes:
    ApiKey:
      type: http
      scheme: bearer

````

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