# Retrieve a custom field

`GET /custom-fields/{resource}/{name}`

> This is a subset of the full specification, limited to the `GET /custom-fields/{resource}/{name}` 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 /custom-fields/{resource}/{name}` 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: Custom fields
    description: |-
      Use custom fields to extend a resource scheme to include custom data that is not provided as a common field.
      Depending on the resource on which the custom field is added, it may be available in the Rebilly UI.

      Example: A custom field called `preferredCommunicationChannel` is added to the customer resource.
      It has two allowed values, which are 'email' and 'phone'.

      ```js
      {
        "customFields": {
            "preferredCommunicationChannel": "email"
        }
      }
      ```

      For detailed information on Rebilly resources, see [Resources](https://www.rebilly.com/docs/dev-docs/concepts/#resources).
x-tagGroups:
  - name: Misc
    tags:
      - Custom fields
paths:
  /custom-fields/{resource}/{name}:
    parameters:
      - $ref: '#/components/parameters/customFieldResource'
      - name: name
        in: path
        description: ID of the custom field.
        required: true
        schema:
          type: string
          maxLength: 60
          pattern: ^[\w-]+$
    get:
      x-products:
        - Core
      tags:
        - Custom fields
      summary: Retrieve a custom field
      operationId: GetCustomField
      x-sdk-operation-name: get
      description: Retrieves a specified custom field schema for a specified resource.
      responses:
        '200':
          description: Custom field schema retrieved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CustomField'
        '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: |
            $customField = $client->customFields()->load('customers', 'testFieldName');
        - lang: JavaScript
          source: |-
            const customField = await api.customFields.get({resource: 'customers', name: 'dob'});
            console.log(customField.fields.description);
        - lang: PHP
          source: |-
            $service = new \Rebilly\Sdk\Service($client);
            $customField = $service->customFields()->get('customers', 'testFieldName');
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:
    customFieldResource:
      name: resource
      in: path
      description: Type of resource schema.
      required: true
      schema:
        type: string
        enum:
          - customers
          - payment-instruments
          - orders
          - subscriptions
          - transactions
          - websites
          - products
          - plans
          - gateway-accounts
          - deposit-requests
  schemas:
    SelfLink:
      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
    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'
    CurrencyCode:
      type: string
      description: Currency code in ISO 4217 format.
      minLength: 3
      maxLength: 3
      example: USD
      x-label: Currency
    ArrayCustomField:
      type: object
      required:
        - type
      properties:
        name:
          description: Name of the custom field.
          type: string
          readOnly: true
        type:
          description: |-
            Describes the data type.
            The custom field type value cannot be changed.

            Array of strings with up to 255 characters.
            The maximum size is 1000 elements.
          type: string
          enum:
            - array
        description:
          description: Description of the custom field.
          type:
            - string
            - 'null'
        isEnabled:
          description: Specifies if the custom field is enabled.
          type: boolean
          default: true
        additionalSchema:
          type:
            - object
            - 'null'
          description: Additional schema which adds additional values constrains.
          properties:
            allowedValues:
              description: List of allowed values.
              type: array
              items:
                type: string
            required:
              description: |-
                Specifies if this value is required.
                This value can be combined with any parameter and is available for custom fields of any type.
              type: boolean
            default:
              description: Default value.
              type: array
              items:
                type: string
        _links:
          $ref: '#/components/schemas/SelfLink'
    BooleanCustomField:
      type: object
      required:
        - type
      properties:
        name:
          description: Name of the custom field.
          type: string
          readOnly: true
        type:
          description: |-
            Describes the data type.
            The custom field type value cannot be changed.

            Specifies a `true` or `false` value.
          type: string
          enum:
            - boolean
        description:
          description: Description of the custom field.
          type:
            - string
            - 'null'
        isEnabled:
          description: Specifies if custom field is enabled.
          type: boolean
          default: true
        additionalSchema:
          type:
            - object
            - 'null'
          description: Additional schema which adds additional values constrains.
          properties:
            required:
              description: Specifies if this value is required.
              type: boolean
            default:
              description: Default value.
              type: boolean
        _links:
          $ref: '#/components/schemas/SelfLink'
    DateCustomField:
      type: object
      required:
        - type
      properties:
        name:
          description: Name of the custom field.
          type: string
          readOnly: true
        type:
          description: |-
            Describes the data type.
            The custom field type value cannot be changed.

            String in [full-date](https://www.rfc-editor.org/rfc/rfc3339) format (YYYY-MM-DD).
          type: string
          enum:
            - date
        description:
          description: Description of the custom field.
          type:
            - string
            - 'null'
        isEnabled:
          description: Specifies if custom field is enabled.
          type: boolean
          default: true
        additionalSchema:
          type:
            - object
            - 'null'
          description: Additional schema which adds additional values constrains.
          properties:
            required:
              description: Specifies if this value is required.
              type: boolean
            default:
              description: Default value.
              type: string
              format: date
        _links:
          $ref: '#/components/schemas/SelfLink'
    DateTimeCustomField:
      type: object
      required:
        - type
      properties:
        name:
          description: Name of the custom field.
          type: string
          readOnly: true
        type:
          description: |-
            Describes the data type.
            The custom field type value cannot be changed.

            String in [date-time](https://www.rfc-editor.org/rfc/rfc3339) format (YYYY-MM-DDTHH:MM:SSZ).
          type: string
          enum:
            - datetime
        description:
          description: Description of the custom field.
          type:
            - string
            - 'null'
        isEnabled:
          description: Specifies if custom field is enabled.
          type: boolean
          default: true
        additionalSchema:
          type:
            - object
            - 'null'
          description: Additional schema which adds additional values constrains.
          properties:
            required:
              description: Specifies if this value is required.
              type: boolean
            default:
              description: Default value.
              type: string
              format: date-time
        _links:
          $ref: '#/components/schemas/SelfLink'
    IntegerCustomField:
      type: object
      required:
        - type
      properties:
        name:
          description: Name of the custom field.
          type: string
          readOnly: true
        type:
          description: |-
            Describes the data type.
            The custom field type value cannot be changed.

            Cardinal value of between `-2^31` and `2^31-1`.
          type: string
          enum:
            - integer
        description:
          description: Description of the custom field.
          type:
            - string
            - 'null'
        isEnabled:
          description: Specifies if custom field is enabled.
          type: boolean
          default: true
        additionalSchema:
          type:
            - object
            - 'null'
          description: Additional schema which adds additional values constrains.
          properties:
            minimum:
              description: |-
                Minimum allowed integer.
                This value can be combined with the `maximum` parameter.
              type: integer
            maximum:
              description: |-
                Maximum allowed integer.
                This value can be combined with the `minimum` parameter.
              type: integer
            required:
              description: Specifies if this value is required.
              type: boolean
            default:
              description: Default value.
              type: integer
        _links:
          $ref: '#/components/schemas/SelfLink'
    NumberCustomField:
      type: object
      required:
        - type
      properties:
        name:
          description: Name of the custom field.
          type: string
          readOnly: true
        type:
          description: |-
            Describes the data type.
            The custom field type value cannot be changed.

            Float value. This field also accepts cardinal values which are interpreted as float.
          type: string
          enum:
            - number
        description:
          description: Description of the custom field.
          type:
            - string
            - 'null'
        isEnabled:
          description: Specifies if custom field is enabled.
          type: boolean
          default: true
        additionalSchema:
          type:
            - object
            - 'null'
          description: Additional schema which adds additional values constrains.
          properties:
            minimum:
              description: |-
                Minimum allowed number.
                This value can be combined with the `maximum` parameter.
              type: number
              format: double
            maximum:
              description: |-
                Maximum allowed number.
                This value can be combined with the `minimum` parameter.
              type: number
              format: double
            required:
              description: Specifies if this value is required.
              type: boolean
            default:
              description: Default value.
              type: number
              format: double
        _links:
          $ref: '#/components/schemas/SelfLink'
    StringCustomField:
      type: object
      required:
        - type
      properties:
        name:
          description: Name of the custom field.
          type: string
          readOnly: true
        type:
          description: |-
            Describes the data type.
            The custom field type cannot be changed.

            Regular string of up to 255 characters.
          type: string
          enum:
            - string
        description:
          description: Description of the custom field.
          type:
            - string
            - 'null'
        isEnabled:
          description: Specifies if custom field is enabled.
          type: boolean
          default: true
        additionalSchema:
          type:
            - object
            - 'null'
          description: Additional schema which adds additional values constrains.
          properties:
            allowedValues:
              description: List of allowed values.
              type: array
              items:
                type: string
            maxLength:
              description: |-
                Maximum allowed string length .
                A maximum length of 4000 characters can be configured.
                By default, this value is set to 255.
              type: integer
            pattern:
              description: Allowed regular expression of a string.
              type: string
              example: /^[0-9]+$/
            required:
              description: Specifies if this value is required.
              type: boolean
            default:
              description: Default value.
              type: string
        _links:
          $ref: '#/components/schemas/SelfLink'
    MonetaryCustomField:
      type: object
      required:
        - type
      properties:
        name:
          description: Name of the custom field.
          type: string
          readOnly: true
        type:
          description: |-
            Describes the data type.
            The custom field type cannot be changed.

            A map of 3-letter currency, code, and amount.
            Example: `{"currency": "EUR", "amount": 25.30}`.
          type: string
          enum:
            - monetary
        description:
          description: Description of the custom field.
          type:
            - string
            - 'null'
        isEnabled:
          description: Specifies if custom field is enabled.
          type: boolean
          default: true
        additionalSchema:
          type:
            - object
            - 'null'
          description: Additional schema which adds additional values constrains.
          properties:
            required:
              description: Specifies if this value is required.
              type: boolean
            default:
              description: Default value.
              type: object
              properties:
                currency:
                  $ref: '#/components/schemas/CurrencyCode'
                amount:
                  type: number
                  format: double
        _links:
          $ref: '#/components/schemas/SelfLink'
    CustomField:
      description: Separate custom field schema.
      type: object
      discriminator:
        propertyName: type
        mapping:
          array: '#/components/schemas/ArrayCustomField'
          boolean: '#/components/schemas/BooleanCustomField'
          date: '#/components/schemas/DateCustomField'
          datetime: '#/components/schemas/DateTimeCustomField'
          integer: '#/components/schemas/IntegerCustomField'
          number: '#/components/schemas/NumberCustomField'
          string: '#/components/schemas/StringCustomField'
          monetary: '#/components/schemas/MonetaryCustomField'
      oneOf:
        - $ref: '#/components/schemas/ArrayCustomField'
        - $ref: '#/components/schemas/BooleanCustomField'
        - $ref: '#/components/schemas/DateCustomField'
        - $ref: '#/components/schemas/DateTimeCustomField'
        - $ref: '#/components/schemas/IntegerCustomField'
        - $ref: '#/components/schemas/NumberCustomField'
        - $ref: '#/components/schemas/StringCustomField'
        - $ref: '#/components/schemas/MonetaryCustomField'
  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'
````
