openapi: 3.1.0
info:
  title: impact.com API - User
  description: |
    Users are the people in your program. In other places a User might also be called a Contact, Lead or Participant. Users are each mapped to one specific account.
    The following information is controlled at the user level: First and last name, Email address, Referral code, Share links, Custom fields.
  version: 2.0.0
servers:
- url: https://app.referralsaasquatch.com/api/v1
  description: Production Server
security:
- basicAuth: []
tags:
- name: User
  description: API for managing users, including creation, lookup, and blocking.
- name: Open Endpoint
  description: Special methods designed for Client-facing applications like the Mobile and Javascript SDKs.
paths:
  /{tenant_alias}/user:
    post:
      summary: Create or Update a User
      operationId: createUser
      tags:
      - User
      description: |
        This method creates or updates a User object by performing an atomic upsert operation.
        This method will not create or update the Account linked by `accountId`.
      security:
      - APIKey: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      requestBody:
        description: Details of the User to be created or updated
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UserStub'
      responses:
        '200':
          description: User Created or Updated
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --request POST \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/user' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Content-Type: application/json' \
            --header 'Accept: */*'
    get:
      summary: Lookup a user by Referral Code
      operationId: findUserByReferralCode
      tags:
      - User
      description: |
        Looks up a user based upon their `referralCode` and returns their personal information.
        This method is useful for retrieving the user when only the Referral Code is available.
      security:
      - APIKey: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - name: referralCode
        in: query
        required: true
        schema:
          type: string
          example: BOBTESTERSON
        description: The `referralCode` of the user you want to retrieve.
      responses:
        '200':
          description: User found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '404':
          description: User NOT found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/user' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Accept: */*'
  /{tenant_alias}/account/{accountId}/user/{userId}:
    get:
      summary: Lookup a user
      operationId: getUser
      tags:
      - User
      description: |
        Looks up a user based upon their `id` and returns their personal information.
        This method just returns the details of the user in question, and not all associated properties like Rewards, Balances, or Referrals.
      security:
      - APIKey: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - $ref: '#/components/parameters/accountId'
      - $ref: '#/components/parameters/userId'
      responses:
        '200':
          description: User found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/User'
        '404':
          description: User NOT found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/account/{accountId}/user/{userId}' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Accept: */*'
  /{tenant_alias}/account/{accountId}/user/{userId}/pii:
    get:
      summary: Lookup a user PII
      operationId: getUserPII
      tags:
      - User
      description: |
        Returns details of the personally identifiable information stored in the impact.com system for a specific user.
        > 🚧 **Warning!** This method should only be used in connection with data protection and privacy compliance.
      security:
      - APIKey: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - $ref: '#/components/parameters/accountId'
      - $ref: '#/components/parameters/userId'
      responses:
        '200':
          description: User found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserPII'
        '404':
          description: User NOT found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/account/{accountId}/user/{userId}/pii' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Accept: */*'
  /{tenant_alias}/account/{accountId}/user/{userId}/block:
    post:
      summary: Block user
      operationId: blockUser
      tags:
      - User
      description: Block a user from making successful referrals based upon their user and account `id`.
      security:
      - APIKey: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - $ref: '#/components/parameters/accountId'
      - $ref: '#/components/parameters/userId'
      responses:
        '200':
          description: User blocked successfully
          content:
            application/json:
              schema:
                type: object
        '404':
          description: User account NOT found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --request POST \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/account/{accountId}/user/{userId}/block' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Accept: */*'
  /{tenant_alias}/account/{accountId}/user/{userId}/unblock:
    post:
      summary: Unblock user
      operationId: unblockUser
      tags:
      - User
      description: Unblock a user based upon their user and account `id`.
      security:
      - APIKey: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - $ref: '#/components/parameters/accountId'
      - $ref: '#/components/parameters/userId'
      responses:
        '200':
          description: User unblocked successfully
          content:
            application/json:
              schema:
                type: object
        '404':
          description: User account NOT found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --request POST \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/account/{accountId}/user/{userId}/unblock' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Accept: */*'
  /{tenant_alias}/users:
    get:
      summary: List users
      operationId: listUsers
      tags:
      - User
      description: |
        List all of the users in your Advocate referral programs.
        This method supports pagination and search queries.
      security:
      - APIKey: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - $ref: '#/components/parameters/query'
      - $ref: '#/components/parameters/limit'
      - $ref: '#/components/parameters/offset'
      responses:
        '200':
          description: Users found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserList'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/users' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Accept: */*'
  /{tenant_alias}/open/account/{accountId}/user/{userId}:
    get:
      summary: Lookup a user (Open Endpoint)
      operationId: openGetUser
      tags:
      - User
      - Open Endpoint
      description: |
        This method looks up a user based on their `id` and returns their personal information including sharelinks. This endpoint requires authentication via a write token or API credentials.
      security:
      - APIKey: []
      - UserJWT: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - $ref: '#/components/parameters/accountId'
      - $ref: '#/components/parameters/userId'
      - $ref: '#/components/parameters/fields'
      - $ref: '#/components/parameters/extraFields'
      responses:
        '200':
          description: User found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenUser'
        '401':
          $ref: '#/components/responses/UnauthorizedError'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/open/account/{accountId}/user/{userId}' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Accept: */*'
    put:
      summary: User Upsert (Open Endpoint)
      operationId: openUserUpsert
      tags:
      - User
      - Open Endpoint
      description: |
        This method updates/creates a user and an account and returns the user object representing that newly created user/account.
        Because this call creates a user, it requires either a write token or an API key.
      security:
      - APIKey: []
      - UserJWT: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - $ref: '#/components/parameters/accountId'
      - $ref: '#/components/parameters/userId'
      - $ref: '#/components/parameters/fields'
      - $ref: '#/components/parameters/extraFields'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenUserUpsert'
      responses:
        '200':
          description: Information about the upserted user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenUser'
        '403':
          $ref: '#/components/responses/ForbiddenError'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --request PUT \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/open/account/{accountId}/user/{userId}' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Content-Type: application/json' \
            --header 'Accept: */*'
    post:
      summary: Create a user and account (Open Endpoint)
      operationId: openCreateUser
      tags:
      - User
      - Open Endpoint
      description: |
        This method creates a user and an account and returns the user object representing that newly created user/account.
        Because this call creates a user, it requires either a write token or an API key.
      security:
      - APIKey: []
      - UserJWT: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - $ref: '#/components/parameters/accountId'
      - $ref: '#/components/parameters/userId'
      - $ref: '#/components/parameters/fields'
      - $ref: '#/components/parameters/extraFields'
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/OpenUserUpsert'
      responses:
        '201':
          description: Information about the newly created user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/OpenUser'
        '403':
          $ref: '#/components/responses/ForbiddenError'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --request POST \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/open/account/{accountId}/user/{userId}' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Content-Type: application/json' \
            --header 'Accept: */*'
    delete:
      summary: Delete a user (Open Endpoint)
      operationId: openDeleteUser
      tags:
      - User
      - Open Endpoint
      description: |
        Delete a user in your impact.com project. By default this endpoint only deletes a User on an Account (and not the Account itself).
      security:
      - APIKey: []
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - $ref: '#/components/parameters/accountId'
      - $ref: '#/components/parameters/userId'
      - name: doNotTrack
        in: query
        description: Do not track this user (this user cannot be re-registered on the same account).
        schema:
          type: boolean
      - name: preserveEmptyAccount
        in: query
        description: Do not delete accounts when all the users in the account are deleted.
        schema:
          type: boolean
      responses:
        '204':
          description: User successfully deleted
        '404':
          $ref: '#/components/responses/NotFoundError'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --request DELETE \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/open/account/{accountId}/user/{userId}' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Accept: */*'
  /{tenant_alias}/open/user:
    get:
      summary: Get a user by a referral code (Open Endpoint)
      operationId: openGetUserByCode
      tags:
      - User
      - Open Endpoint
      security: []
      description: |
        Looks up a user based upon their `ReferralCode` and returns their personal information. This is an [Open Endpoint](https://integrations.impact.com/impact-brand/reference/api-open-endpoints) and disabled by default.
      parameters:
      - $ref: '#/components/parameters/tenant_alias'
      - name: referralCode
        in: query
        required: true
        schema:
          type: string
        description: The code with which to lookup the user.
      responses:
        '200':
          description: Found user
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UserByCode'
        '403':
          $ref: '#/components/responses/ForbiddenError'
        '404':
          $ref: '#/components/responses/NotFoundError'
      x-codeSamples:
      - lang: cURL
        source: |-
          curl -L \
            --url 'https://app.referralsaasquatch.com/api/v1/{tenant_alias}/open/user' \
            --user '{AccountSID}:{AuthToken}' \
            --header 'Accept: */*'
components:
  securitySchemes:
    basicAuth:
      type: http
      scheme: basic
      description: Use your AccountSID as the username and AuthToken as the password.
    APIKey:
      type: http
      scheme: basic
      description: Authorize your requests using a tenant's API Key. Use this method only in server-to-server interactions.
    UserJWT:
      type: apiKey
      in: header
      name: X-SaaSquatch-User-Token
      description: A JWT for a given user. Used by the Mobile and Web SDKs and other client-side contexts via Open Endpoints.
  schemas:
    UserStub:
      description: Request body for creating or updating a user.
      required:
      - id
      - accountId
      properties:
        id:
          type: string
          description: The unique identifier for the user.
          example: abc123
        accountId:
          type: string
          description: The unique identifier of the account the user belongs to.
          example: abc123
        firstName:
          type: string
          description: The user's first name.
          example: Bob
        lastName:
          type: string
          description: The user's last name.
          example: Testerson
        email:
          type: string
          format: email
          description: The user's email address.
          example: bob.testerson@example.com
        locale:
          type: string
          description: The user's locale (e.g. `en_US`).
          example: en_US
        countryCode:
          type: string
          description: The user's ISO 3166-1 Alpha-2 country code (e.g. `US`).
          example: US
        referralCode:
          type: string
          description: A custom referral code to assign to the user.
          example: BOBTESTERSON
        customFields:
          type: object
          additionalProperties: true
          description: Custom fields for this user.
    User:
      description: A user in the impact.com referral program.
      type: object
      properties:
        id:
          type: string
          description: The unique identifier for the user.
          example: abc123
        accountId:
          type: string
          description: The unique identifier of the account the user belongs to.
          example: abc123
        firstName:
          type: string
          description: The user's first name.
          example: Bob
        lastName:
          type: string
          description: The user's last name.
          example: Testerson
        lastInitial:
          type: string
          description: The first initial of the user's last name.
          example: T
        email:
          type: string
          format: email
          description: The user's email address.
          example: bob.testerson@example.com
        emailHash:
          type: string
          description: An MD5 hash of the user's email address.
          example: 714ed06b2d5c95b93d499a3be731c19f
        imageUrl:
          type: string
          description: URL of the user's profile image. Empty string if not set.
          example: ""
        referralCode:
          type: string
          description: The user's primary referral code.
          example: CFMVQHNUEU2AWWDO
        cookieId:
          type: string
          nullable: true
          description: The cookie ID associated with this user.
          example: abc123cookie
        paymentProviderId:
          type: string
          nullable: true
          description: The ID of the user in the payment provider system.
          example: pay_abc123
        locale:
          type: string
          nullable: true
          description: The user's locale (e.g. `en_US`).
          example: en_US
        countryCode:
          type: string
          nullable: true
          description: The user's ISO 3166-1 Alpha-2 country code (e.g. `US`).
          example: US
        referralSource:
          type: string
          nullable: true
          description: The source of the user's referral.
          example: DIRECT
        firstSeenIP:
          type: string
          nullable: true
          description: The IP address the user was first seen from.
          example: "203.0.113.42"
        lastSeenIP:
          type: string
          nullable: true
          description: The IP address the user was last seen from.
          example: "203.0.113.42"
        dateCreated:
          type: integer
          format: int64
          description: Unix timestamp (milliseconds) when the user was created.
          example: 1774386824964
        dateBlocked:
          type: integer
          format: int64
          nullable: true
          description: Unix timestamp (milliseconds) when the user was blocked. Null if not blocked.
          example: 1779871222634
        shareLinks:
          $ref: '#/components/schemas/Sharelink'
    UserPII:
      description: Full personally identifiable information for a user, including rewards, referrals, and share links. Only use in connection with data protection and privacy compliance.
      type: object
      properties:
        id:
          type: string
          description: The unique identifier for the user.
          example: abc123
        accountId:
          type: string
          description: The unique identifier of the account the user belongs to.
          example: abc123
        firstName:
          type: string
          description: The user's first name.
          example: Bob
        lastName:
          type: string
          description: The user's last name.
          example: Testerson
        lastInitial:
          type: string
          description: The first initial of the user's last name.
          example: T
        email:
          type: string
          format: email
          description: The user's email address.
          example: bob.testerson@example.com
        emailHash:
          type: string
          description: An MD5 hash of the user's email address.
          example: 714ed06b2d5c95b93d499a3be731c19f
        imageUrl:
          type: string
          description: URL of the user's profile image.
          example: ""
        cookieId:
          type: string
          nullable: true
          description: The cookie ID associated with this user.
          example: abc123cookie
        paymentProviderId:
          type: string
          nullable: true
          description: The ID of the user in the payment provider system.
          example: pay_abc123
        locale:
          type: string
          nullable: true
          description: The user's locale (e.g. `en_US`).
          example: en_US
        countryCode:
          type: string
          nullable: true
          description: The user's ISO 3166-1 Alpha-2 country code (e.g. `US`).
          example: US
        referable:
          type: boolean
          description: Whether this user can be referred by another user.
          example: true
        referralSource:
          type: string
          nullable: true
          description: The source of the user's referral.
          example: UNKNOWN
        referralCodes:
          type: object
          additionalProperties:
            type: string
          description: A map of program IDs to the user's referral code for that program.
          example: {"47255": "BOBTESTERSON"}
        firstSeenIP:
          type: string
          nullable: true
          description: The IP address the user was first seen from.
          example: "203.0.113.42"
        lastSeenIP:
          type: string
          nullable: true
          description: The IP address the user was last seen from.
          example: "203.0.113.42"
        firstSeenIPLocation:
          type: string
          nullable: true
          description: The geographic location derived from `firstSeenIP`.
          example: "San Francisco, CA, US"
        lastSeenIPLocation:
          type: string
          nullable: true
          description: The geographic location derived from `lastSeenIP`.
          example: "San Francisco, CA, US"
        firstSeenUserAgent:
          type: string
          nullable: true
          description: The browser user agent string from the user's first session.
          example: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36"
        lastSeenUserAgent:
          type: string
          nullable: true
          description: The browser user agent string from the user's most recent session.
          example: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36"
        dateCreated:
          type: integer
          format: int64
          description: Unix timestamp (milliseconds) when the user was created.
          example: 1774386824964
        customFields:
          type: object
          additionalProperties: true
          description: Custom fields for this user.
        programShareLinks:
          $ref: '#/components/schemas/ProgramShareLink'
        referredByCodes:
          type: array
          items:
            type: string
          description: Referral codes used to refer this user.
          example: ["NCC8IQ4ADTVDQAOA"]
        referredByReferrals:
          type: array
          description: Referral records where this user was the referred party.
          items:
            type: object
            properties:
              id:
                type: string
                description: The unique identifier for the referral.
                example: ref_abc123
              moderationStatus:
                type: string
                description: The moderation status of the referral.
                example: ACTIONED
              dateReferralStarted:
                type: integer
                format: int64
                description: Unix timestamp (milliseconds) when the referral started.
                example: 1774386824964
              dateReferralPaid:
                type: integer
                format: int64
                nullable: true
                description: Unix timestamp (milliseconds) when the referral was paid.
              dateReferralEnded:
                type: integer
                format: int64
                nullable: true
                description: Unix timestamp (milliseconds) when the referral ended.
              dateModerated:
                type: integer
                format: int64
                nullable: true
                description: Unix timestamp (milliseconds) when the referral was moderated.
              referredModerationStatus:
                type: string
                description: The moderation status of the referred user.
                example: APPROVED
              referrerModerationStatus:
                type: string
                description: The moderation status of the referrer.
                example: APPROVED
              programId:
                type: string
                nullable: true
                description: The program ID associated with this referral.
                example: "47255"
              referredReward:
                type: object
                nullable: true
                description: The reward earned by the referred user.
              referrerReward:
                type: object
                nullable: true
                description: The reward earned by the referrer.
              publicMeta:
                type: object
                nullable: true
                description: Public metadata associated with the referral.
              privateMeta:
                type: object
                nullable: true
                description: Private metadata associated with the referral.
              fraudSignals:
                type: object
                nullable: true
                description: Fraud signals detected for this referral.
        rewards:
          type: object
          description: A paginated list of rewards earned by this user.
          properties:
            totalCount:
              type: integer
              description: Total number of rewards.
              example: 1
            data:
              type: array
              items:
                type: object
        rewardBalances:
          type: array
          description: Aggregated reward balance summaries for this user.
          items:
            type: object
            properties:
              type:
                type: string
                description: The reward type.
                example: CREDIT
              unit:
                type: string
                description: The unit of the reward.
                example: CENTS
              count:
                type: integer
                description: Number of rewards of this type.
                example: 1
              totalAssignedCredit:
                type: integer
                description: Total credit assigned.
                example: 100
              totalRedeemedCredit:
                type: integer
                description: Total credit redeemed.
                example: 0
              totalPendingCredit:
                type: integer
                description: Total credit pending.
                example: 0
              totalExpiredCredit:
                type: integer
                description: Total credit expired.
                example: 0
              totalCancelledCredit:
                type: integer
                description: Total credit cancelled.
                example: 0
              prettyAssignedCredit:
                type: string
                description: Human-readable total assigned credit.
                example: "$1.00"
              prettyRedeemedCredit:
                type: string
                description: Human-readable total redeemed credit.
                example: "$0.00"
              prettyPendingCredit:
                type: string
                description: Human-readable total pending credit.
                example: "$0.00"
              value:
                type: integer
                description: The available (unredeemed) credit balance.
                example: 100
              prettyValue:
                type: string
                description: Human-readable available balance.
                example: "$1.00"
        referrals:
          type: object
          description: A paginated list of referrals made by this user.
          properties:
            totalCount:
              type: integer
              description: Total number of referrals.
              example: 0
            data:
              type: array
              items:
                type: object
        segments:
          type: array
          items:
            type: string
          description: The segments this user belongs to.
    UserList:
      type: object
      properties:
        count:
          type: integer
        totalCount:
          type: integer
        users:
          type: array
          items:
            $ref: '#/components/schemas/User'
    OpenUser:
      description: A user object returned by open endpoints. Includes program share links and custom fields.
      type: object
      properties:
        id:
          type: string
          description: The unique identifier for the user.
          example: abc123
        accountId:
          type: string
          description: The unique identifier of the account the user belongs to.
          example: abc123
        firstName:
          type: string
          description: The user's first name.
          example: Bob
        lastName:
          type: string
          description: The user's last name.
          example: Testerson
        email:
          type: string
          format: email
          description: The user's email address.
          example: bob.testerson@example.com
        imageUrl:
          type: string
          description: URL of the user's profile image.
          example: ""
        cookieId:
          type: string
          nullable: true
          description: The cookie ID associated with this user.
          example: abc123cookie
        locale:
          type: string
          nullable: true
          description: The user's locale (e.g. `en_US`).
          example: en_US
        countryCode:
          type: string
          nullable: true
          description: The user's ISO 3166-1 Alpha-2 country code (e.g. `US`).
          example: US
        referable:
          type: boolean
          description: Whether this user can be referred by another user.
          example: true
        firstSeenIP:
          type: string
          nullable: true
          description: The IP address the user was first seen from.
          example: "203.0.113.42"
        lastSeenIP:
          type: string
          nullable: true
          description: The IP address the user was last seen from.
          example: "203.0.113.42"
        dateCreated:
          type: integer
          format: int64
          description: Unix timestamp (milliseconds) when the user was created.
          example: 1774386824964
        referralCodes:
          type: object
          additionalProperties:
            type: string
          description: A map of program IDs to the user's referral code for that program.
          example: {"47255": "BOBTESTERSON"}
        programShareLinks:
          $ref: '#/components/schemas/ProgramShareLink'
        customFields:
          type: object
          additionalProperties: true
          description: Custom fields for this user.
        segments:
          type: array
          items:
            type: string
          description: The segments this user belongs to.
        referredByCodes:
          type: array
          items:
            type: string
          description: Referral codes used to refer this user.
          example: ["NCC8IQ4ADTVDQAOA"]
    UserByCode:
      description: Minimal user information returned when looking up a user by referral code from the open endpoint.
      type: object
      properties:
        id:
          type: string
          description: The unique identifier for the user.
          example: abc123
        accountId:
          type: string
          description: The unique identifier of the account the user belongs to.
          example: abc123
        firstName:
          type: string
          description: The user's first name.
          example: Bob
        lastInitial:
          type: string
          description: The first initial of the user's last name.
          example: T
        referralCode:
          type: string
          description: The user's primary referral code.
          example: CFMVQHNUEU2AWWDO
        imageUrl:
          type: string
          description: URL of the user's profile image.
          example: ""
    OpenUserStub:
      description: Request body for creating or updating a user via an open endpoint.
      allOf:
      - $ref: '#/components/schemas/OpenUserUpsert'
    OpenUserUpsert:
      title: A Open User object for Upsert/Create
      description: An object describing an individual user submitted to an open endpoint when you want to create or update a user.
      required:
      - id
      - accountId
      properties:
        id:
          type: string
          description: The unique identifier provided for this user. Use the user's email as their user Id.
          example: bob.testerson@example.com
        accountId:
          type: string
          description: The unique identifier of the account. Value must match `id`. Use the user's email as their account Id.
          example: bob.testerson@example.com
        firstName:
          type: string
          description: The user's first name.
          example: Bob
        lastName:
          type: string
          description: The user's last name.
          example: Testerson
        email:
          type: string
          format: email
          description: The email address provided for the user.
          example: bob.testerson@example.com
        referable:
          type: boolean
          description: Flag to determine whether a user is able to be referred.
        referralCodes:
          type: object
          additionalProperties:
            type: string
          description: The primary custom referral codes for different programs, mapping `programId` to `code`.
        locale:
          type: string
          description: The user's locale, used for Internationalization (e.g., `en_US`).
          example: en_US
        countryCode:
          type: string
          description: The user's ISO 3166-1 Alpha-2 country code (e.g., `US`).
          example: US
        dateUsTaxFormSubmitted:
          type: integer
          format: int64
          description: The timestamp of when a user's W-9 tax form was submitted.
        referredByCodes:
          type: array
          items:
            type: string
          description: An array of referral codes used to refer this account.
        cookies:
          type: string
          description: The Base64URL encoded attribution cookie values.
          example: eyJjb29raWVJZCI6ImFiYzEyMyJ9
        segments:
          type: array
          items:
            type: string
          description: A list of operations for adding and removing a user from segments (e.g., `["segment1", "~segment2"]`).
        shareLinks:
          type: object
          additionalProperties:
            type: string
          description: The primary custom shareLinks for different programs, mapping `programId` to `sharelink`.
        customFields:
          type: object
          additionalProperties: true
          description: An object containing the custom fields for this user.
    Error:
      properties:
        statusCode:
          description: The HTTP status code of the error.
          type: integer
          format: int32
          example: 404
        message:
          description: The human-readable description of what went wrong. Use this to help you debug.
          type: string
        apiErrorCode:
          description: A machine-readable error code.
          type: string
        rsCode:
          description: A secondary machine-readable error code.
          type: string
          example: RS042
    Sharelink:
      description: Legacy flat-format share links for a user, organised by share medium and engagement medium.
      type: object
      properties:
        shareLink:
          type: string
          format: uri
          description: The user's primary share link.
          example: https://share.impact.squatchtesting.com/mvbnEye
        facebookShareLink:
          type: string
          format: uri
          description: The share link for Facebook.
          example: https://share.impact.squatchtesting.com/mmbnEye
        twitterShareLink:
          type: string
          format: uri
          description: The share link for Twitter.
          example: https://share.impact.squatchtesting.com/mRbnEye
        emailShareLink:
          type: string
          format: uri
          description: The share link for Email.
          example: https://share.impact.squatchtesting.com/mLbnEye
        linkedinShareLink:
          type: string
          format: uri
          description: The share link for LinkedIn.
          example: https://share.impact.squatchtesting.com/m6bnEye
        mobileShareLink:
          type: string
          format: uri
          description: The share link for mobile devices.
          example: https://share.impact.squatchtesting.com/mebnEye
        mobileFacebookShareLink:
          type: string
          format: uri
          description: The share link for Facebook on mobile.
          example: https://share.impact.squatchtesting.com/mnbnEye
        mobileTwitterShareLink:
          type: string
          format: uri
          description: The share link for Twitter on mobile.
          example: https://share.impact.squatchtesting.com/mCbnEye
        mobileEmailShareLink:
          type: string
          format: uri
          description: The share link for Email on mobile.
          example: https://share.impact.squatchtesting.com/mEbnEye
        EMBED:
          $ref: '#/components/schemas/SharelinkEngagementMedium'
        POPUP:
          $ref: '#/components/schemas/SharelinkEngagementMedium'
        HOSTED:
          $ref: '#/components/schemas/SharelinkEngagementMedium'
        MOBILE:
          $ref: '#/components/schemas/SharelinkEngagementMedium'
        EMAIL:
          $ref: '#/components/schemas/SharelinkEngagementMedium'
    SharelinkEngagementMedium:
      description: Share links for a single engagement medium in the legacy flat format.
      type: object
      properties:
        shareLink:
          type: string
          format: uri
          description: The primary share link for this engagement medium.
          example: https://share.impact.squatchtesting.com/mvbnEye
        facebookShareLink:
          type: string
          format: uri
          description: The Facebook share link for this engagement medium.
          example: https://share.impact.squatchtesting.com/mmbnEye
        twitterShareLink:
          type: string
          format: uri
          description: The Twitter share link for this engagement medium.
          example: https://share.impact.squatchtesting.com/mRbnEye
        emailShareLink:
          type: string
          format: uri
          description: The Email share link for this engagement medium.
          example: https://share.impact.squatchtesting.com/mLbnEye
        linkedinShareLink:
          type: string
          format: uri
          description: The LinkedIn share link for this engagement medium.
          example: https://share.impact.squatchtesting.com/m6bnEye
    ProgramShareLink:
      description: A map of program IDs to share link sets for that program.
      type: object
      additionalProperties:
        type: object
        properties:
          cleanShareLink:
            type: string
            format: uri
            description: The clean (unencoded) primary share link for this program.
            example: https://share.impact.squatchtesting.com/mzbnEyE
          UNKNOWN:
            type: object
            additionalProperties:
              type: string
              format: uri
          EMAIL:
            type: object
            additionalProperties:
              type: string
              format: uri
          MOBILE:
            type: object
            additionalProperties:
              type: string
              format: uri
          EMBED:
            type: object
            additionalProperties:
              type: string
              format: uri
          POPUP:
            type: object
            additionalProperties:
              type: string
              format: uri
          HOSTED:
            type: object
            additionalProperties:
              type: string
              format: uri
  parameters:
    tenant_alias:
      name: tenant_alias
      in: path
      description: Tenant being referenced. E.g. `"aboih12h16t"`
      required: true
      schema:
        type: string
    accountId:
      name: accountId
      in: path
      description: The ID of the account.
      required: true
      schema:
        type: string
    userId:
      name: userId
      in: path
      description: The ID of the user.
      required: true
      schema:
        type: string
    query:
      name: query
      in: query
      description: A search query that can be used to filter users by email, name or ID.
      schema:
        type: string
    limit:
      name: limit
      in: query
      description: A limit on the number of results returned.
      schema:
        type: integer
        default: 10
    offset:
      name: offset
      in: query
      description: When included, offsets the first result returned in the list.
      schema:
        type: integer
        default: 0
    fields:
      name: fields
      in: query
      schema:
        type: string
      description: The fields to be included in the response. Cannot coexist with `extraFields`.
      style: form
      explode: false
    extraFields:
      name: extraFields
      in: query
      schema:
        type: string
      description: The fields to be included in the response in addition to all the default fields. Cannot coexist with `fields`.
      style: form
      explode: false
  responses:
    GeneralError:
      description: Unexpected Error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    NotFoundError:
      description: Not Found
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    ForbiddenError:
      description: Forbidden/Endpoint Disabled
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnauthorizedError:
      description: Unauthorized
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
x-default-client: cURL
