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

# Get Referral Program

> Fetch a referral program by ID.

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

### Body Parameters

<DynamicParamField body="referral_program_id" type="string" required>
  The ID of the referral program.
</DynamicParamField>

### Response

<DynamicResponseField name="id" type="string">
  The unique identifier for the referral program.
</DynamicResponseField>

<DynamicResponseField name="reward_id" type="string">
  The ID of the reward granted when a code is redeemed.
</DynamicResponseField>

<DynamicResponseField name="redeem_on" type="'customer_creation' | 'checkout'">
  When the reward is granted: on redemption, or when the redeemer checks out.
</DynamicResponseField>

<DynamicResponseField name="received_by" type="'referrer' | 'all'">
  Who receives the reward: the referrer only, or both parties.
</DynamicResponseField>

<DynamicResponseField name="max_redemptions" type="number | null">
  The maximum number of times a referral code can be redeemed.
</DynamicResponseField>

<DynamicResponseField name="plan_ids" type="string[] | null">
  The plans whose checkout triggers the reward. Only used when redeem\_on is checkout.
</DynamicResponseField>

<DynamicResponseField name="exclude_trial" type="boolean | null">
  Whether checkouts that start a trial should skip granting the reward.
</DynamicResponseField>

<DynamicResponseField name="created_at" type="number">
  The Unix timestamp (in milliseconds) when the referral program was created.
</DynamicResponseField>

<ResponseExample>
  ```json 200 theme={null}
  {
    "id": "refer_a_friend",
    "reward_id": "beta_credits_grant",
    "redeem_on": "customer_creation",
    "received_by": "referrer",
    "max_redemptions": 10,
    "plan_ids": null,
    "exclude_trial": false,
    "created_at": 1718000000000
  }
  ```
</ResponseExample>


## OpenAPI

````yaml openapi POST /v1/referral_programs.get
openapi: 3.1.0
info:
  title: Autumn API
  version: 2.3.0
servers:
  - url: https://api.useautumn.com
    description: Production server
security:
  - secretKey: []
paths:
  /v1/referral_programs.get:
    post:
      tags:
        - referrals
      description: Fetch a referral program by ID.
      operationId: getReferralProgram
      parameters:
        - name: x-api-version
          in: header
          required: true
          schema:
            type: string
            default: 2.3.0
          x-speakeasy-globals-hidden: true
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                referral_program_id:
                  type: string
                  minLength: 1
                  description: The ID of the referral program.
              required:
                - referral_program_id
              additionalProperties: false
              title: GetReferralProgramParams
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  id:
                    type: string
                    description: The unique identifier for the referral program.
                  reward_id:
                    type: string
                    description: The ID of the reward granted when a code is redeemed.
                  redeem_on:
                    enum:
                      - customer_creation
                      - checkout
                    type: string
                    description: >-
                      When the reward is granted: on redemption, or when the
                      redeemer checks out.
                  received_by:
                    enum:
                      - referrer
                      - all
                    type: string
                    description: >-
                      Who receives the reward: the referrer only, or both
                      parties.
                  max_redemptions:
                    anyOf:
                      - type: number
                      - type: 'null'
                    description: >-
                      The maximum number of times a referral code can be
                      redeemed.
                  plan_ids:
                    anyOf:
                      - type: array
                        items:
                          type: string
                      - type: 'null'
                    description: >-
                      The plans whose checkout triggers the reward. Only used
                      when redeem_on is checkout.
                  exclude_trial:
                    anyOf:
                      - type: boolean
                      - type: 'null'
                    description: >-
                      Whether checkouts that start a trial should skip granting
                      the reward.
                  created_at:
                    type: number
                    description: >-
                      The Unix timestamp (in milliseconds) when the referral
                      program was created.
                required:
                  - id
                  - reward_id
                  - redeem_on
                  - received_by
                  - created_at
                title: GetReferralProgramResponse
                examples:
                  - id: refer_a_friend
                    reward_id: beta_credits_grant
                    redeem_on: customer_creation
                    received_by: referrer
                    max_redemptions: 10
                    plan_ids: null
                    exclude_trial: false
                    created_at: 1718000000000
              example:
                id: refer_a_friend
                reward_id: beta_credits_grant
                redeem_on: customer_creation
                received_by: referrer
                max_redemptions: 10
                plan_ids: null
                exclude_trial: false
                created_at: 1718000000000
      x-codeSamples:
        - lang: typescript
          label: Typescript (SDK)
          source: |-
            import { Autumn } from 'autumn-js'

            const autumn = new Autumn()

            const result = await autumn.referrals.getProgram({
              referralProgramId: "<id>",
            });
        - lang: python
          label: Python (SDK)
          source: |-
            from autumn_sdk import Autumn

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

            res = autumn.referrals.get_program(
                referral_program_id="<id>",
            )
components:
  securitySchemes:
    secretKey:
      type: http
      scheme: bearer
      bearerFormat: JWT

````