# Retrieve a customer's lead source

`GET /customers/{id}/lead-source`

> This is a subset of the full specification, limited to the `GET /customers/{id}/lead-source` operation.
>
> You can find the full specification here: /_bundle/docs/dev-docs/api/index.yaml

```yaml
openapi: 3.1.1
info:
  version: latest
  title: Core APIs
  contact:
    name: Rebilly API Support
    url: https://www.rebilly.com/contact/
    email: integrations@rebilly.com
  license:
    name: Rebilly
    url: https://www.rebilly.com/api-license/
  termsOfService: https://www.rebilly.com/terms-of-use/
  x-logo:
    url: https://rebilly-core.redoc.ly/rb_apiLogo.svg
    backgroundColor: '#0044d4'
  description: This is a subset of the full specification, limited to the `GET /customers/{id}/lead-source` operation.
  x-metadata:
    description: The most common APIs used to automate common workflows.
    redocly_category: API Reference
servers:
  - url: https://api-sandbox.rebilly.com/organizations/{organizationId}
    description: Sandbox server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
  - url: https://api.rebilly.com/organizations/{organizationId}
    description: Live server
    variables:
      organizationId:
        default: '{organizationId}'
        description: |-
          Unique organization identifier.
          An organization is an entity that represents a company.
          For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
security:
  - SecretApiKey: []
  - JWT: []
tags:
  - name: Customers
    description: |-
      Use these operations to manage customers.
      A customer is an entity that purchases goods or services from you (a merchant),
      and is the payee in any transaction that is credited to you.
      Customers are associated with payment instruments,
      subscriptions, invoices, and other related resources.

      In other systems, customers may be referred to as accounts,
      clients, members, patrons, or players.
      For information on the customer resource, see [Resources](https://www.rebilly.com/docs/dev-docs/concepts/#resources).
x-tagGroups:
  - name: Customers
    tags:
      - Customers
paths:
  /customers/{id}/lead-source:
    parameters:
      - $ref: '#/components/parameters/resourceId'
    get:
      x-products:
        - Core
      tags:
        - Customers
      summary: Retrieve a customer's lead source
      operationId: GetCustomerLeadSource
      x-sdk-operation-name: getLeadSource
      description: |-
        Retrieves lead source data for a customer with a specified ID.

        A lead source is the marketing campaign that generates customer interaction, a sale, or a trial.
        For more information, see [Lead source attribution](https://www.rebilly.com/docs/dev-docs/customers/#lead-source-attribution).
      responses:
        '200':
          description: Lead source retrieved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/LeadSource'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '403':
          $ref: '#/components/responses/Forbidden'
        '404':
          $ref: '#/components/responses/NotFound'
      x-codeSamples:
        - lang: PHP
          label: PHP-SDK-2.0
          source: |
            $customer = $client->customers()->load('myCustomerId');
            $leadSource = $customer->getLeadSource();
        - lang: JavaScript
          source: |-
            const lead = await api.customers.getLeadSource({id: 'my-second-id'});
            console.log(lead.fields.affiliate);
        - lang: PHP
          source: |-
            $service = new \Rebilly\Sdk\Service($client);
            $customerLeadSource = $service->customers()->getLeadSource('customerId');
components:
  securitySchemes:
    JWT:
      description: |-
        JWT is a short lifetime token that can be assigned a specific expiration time.

        Usage format: `Bearer <JWT>`.
      type: http
      scheme: bearer
      bearerFormat: JWT
    SecretApiKey:
      description: |-
        Never share your secret keys.
        Keep them guarded and secure.

        Use your secret API key only to make requests from the server side.
        To authenticate, provide your secret key in the request header.
      name: REB-APIKEY
      type: apiKey
      in: header
  parameters:
    resourceId:
      name: id
      in: path
      description: ID of the resource.
      required: true
      schema:
        type: string
        maxLength: 50
        pattern: ^[@~\-\.\w]+$
  schemas:
    CreatedTime:
      type: string
      description: |-
        Date and time when the resource is created.
        This value is set automatically when the resource is created.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Creation Time
    UpdatedTime:
      type: string
      description: |-
        Date and time when the resource is updated.
        This value is set automatically when the resource is updated.
      format: date-time
      readOnly: true
      x-sortable: true
      x-label: Last Update Time
    BaseProblem:
      type: object
      additionalProperties: true
      minProperties: 1
      description: RFC-7807 [problem details](https://tools.ietf.org/html/rfc7807) JSON object.
      properties:
        type:
          type: string
          description: |-
            Problem type in the form of a [URI](https://tools.ietf.org/html/rfc3986) reference.
            It should provide human-readable documentation for the problem type.
            When this member is not present, its value is assumed to be "about:blank".
          format: uri
        title:
          type: string
          description: |-
            Short, human-readable summary of the problem type.
            Other than for the purposes of localization, this should not change from occurrence to occurrence of the problem.
        detail:
          type: string
          description: Human-readable explanation that is specific to this occurrence of the problem.
        instance:
          type: string
          description: |-
            URI reference that identifies the specific occurrence of the problem.
            It may or may not yield further information if dereferenced.
    Unauthorized:
      allOf:
        - title: Unauthorized
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 401
              maximum: 401
        - $ref: '#/components/schemas/BaseProblem'
    OrganizationId:
      type: string
      description: |-
        Unique organization identifier.
        An organization is an entity that represents a company.
        For more information, see [Obtain an organization ID](https://www.rebilly.com/docs/settings/organizations-and-websites/#obtain-your-organization-id-and-website-id).
      maxLength: 50
      example: org_0YVDM8RC7GDADADSBSMW124JA8
    Forbidden:
      allOf:
        - title: Forbidden
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 403
              maximum: 403
            error:
              type: string
              description: |-
                Message that describes why the request is forbidden.
                Most responses use a descriptive message, such as `Not allowed to change security settings`.
                If the organization requires multi-factor authentication (MFA) and MFA verification has not been completed for the session, this value is `mfa_required`.
                If MFA verification has not been completed for the session and the operation requires a confirmed session, this value is `mfa_required_for_caller`.
                This includes turning on `requireMfa` and resetting MFA for a user.
                If the organization restricts access to a list of IP addresses and the request comes from an IP address that is not in the list, this value is `ip_not_allowed`.
            organizationId:
              description: |-
                ID of the organization that requires MFA or does not allow the IP address of the request.
                This property is present only if `error` is `mfa_required` or `ip_not_allowed`.
                The organization is the organization of the request or another organization that the request acts on.
              $ref: '#/components/schemas/OrganizationId'
        - $ref: '#/components/schemas/BaseProblem'
    NotFound:
      allOf:
        - type: object
          properties:
            status:
              type: integer
              description: HTTP status code.
              minimum: 404
              maximum: 404
        - $ref: '#/components/schemas/BaseProblem'
    LeadSourceData:
      type: object
      description: Lead source information.
      properties:
        medium:
          description: |-
            Category of the lead source traffic.
            For example, the medium could be organic search, Google ads, Display ads, and so on.
          type:
            - string
            - 'null'
          maxLength: 512
        source:
          description: Domain, platform, or channel from which the lead source originates.
          type:
            - string
            - 'null'
          maxLength: 512
        campaign:
          description: Campaign name of the lead source.
          type:
            - string
            - 'null'
          maxLength: 512
        term:
          description: Term associated with a lead source.
          type:
            - string
            - 'null'
          maxLength: 512
        content:
          description: |-
            Content contained in the lead source content.
            For example, content could be graphics, video, and so on.
          type:
            - string
            - 'null'
          maxLength: 512
        affiliate:
          description: Individual or entity that is affiliated with the lead source.
          type:
            - string
            - 'null'
          maxLength: 512
        subAffiliate:
          description: |-
            Individual or entity that is associated with a lead source affiliate.
            In other products, this field may also be referred to as sub ID or click ID in some.
          type:
            - string
            - 'null'
          maxLength: 512
        salesAgent:
          description: Name of the sales agent associated with the lead source.
          type:
            - string
            - 'null'
          maxLength: 512
        clickId:
          description: |-
            ID of the lead source click.
            This value is passed in the ad click URL for tracking and campaign attribution.
          type:
            - string
            - 'null'
          maxLength: 512
        path:
          description: URL from which the lead source originates.
          type:
            - string
            - 'null'
          maxLength: 512
        referrer:
          description: Lead source [`referrer` URL](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer).
          type:
            - string
            - 'null'
          format: uri
          maxLength: 2083
          example: https://www.rebilly.com
        createdTime:
          $ref: '#/components/schemas/CreatedTime'
        updatedTime:
          $ref: '#/components/schemas/UpdatedTime'
        _links:
          type: array
          description: Related links.
          readOnly: true
          items:
            type: object
            properties:
              href:
                description: Link URL.
                type: string
              rel:
                description: Type of link.
                type: string
                enum:
                  - self
                  - customer
    LeadSource:
      allOf:
        - $ref: '#/components/schemas/LeadSourceData'
        - type: object
          properties:
            original:
              readOnly: true
              allOf:
                - $ref: '#/components/schemas/LeadSourceData'
  responses:
    Unauthorized:
      description: |-
        Unauthorized access.
        Invalid credentials used.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Unauthorized'
    Forbidden:
      description: |-
        Access forbidden.
        If the organization requires multi-factor authentication (MFA) and the session has not passed MFA, `error` is `mfa_required`.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Forbidden'
    NotFound:
      description: Resource not found.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/NotFound'
```
