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

# Get a customer

> Get a customer by their ID in the organization

**Permissions**: `customers.read`



## OpenAPI

````yaml https://api.moflay.com/openapi get /v1/customers/{id}
openapi: 3.1.0
info:
  title: Moflay API
  description: The fastest way to add M-Pesa payments.
  version: 1.0.0
  contact:
    name: Moflay Support
    email: support@moflay.com
    url: https://moflay.com
  termsOfService: https://moflay.com/legal/terms-of-service
servers:
  - url: https://api.moflay.com
    description: Production server
security:
  - token: []
tags:
  - name: Customers
    description: Create and manage customers in the organization
  - name: Transactions
    description: Everything about transactions in the organization
  - name: Express
    description: >-
      Create M-Pesa Express payments. Use the returned paymentId with the
      Payments API to read status.
  - name: Payments
    description: >-
      Track payment lifecycle and status for paymentIds returned by Express
      payment creation.
externalDocs:
  url: https://moflay.com/docs
  description: Moflay Documentation
paths:
  /v1/customers/{id}:
    get:
      tags:
        - Customers
      summary: Get a customer
      description: |-
        Get a customer by their ID in the organization

        **Permissions**: `customers.read`
      operationId: getCustomer
      parameters:
        - schema:
            allOf:
              - $ref: '#/components/schemas/CustomerId'
              - description: Unique identifier for the customer, prefixed with 'cus_'.
          required: true
          description: Unique identifier for the customer, prefixed with 'cus_'.
          name: id
          in: path
      responses:
        '200':
          description: Get One Customer
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/Customer'
                  - description: Get One Customer
        '401':
          description: Missing API Key Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MissingApiKeyError'
        '403':
          description: Invalid API Key Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InvalidApiKeyError'
        '404':
          description: Customer Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFoundError'
        '405':
          description: Method Not Allowed Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MethodNotAllowedError'
        '422':
          description: The validation error(s) or invalid access error
          content:
            application/json:
              schema:
                anyOf:
                  - $ref: '#/components/schemas/ValidationError'
                  - $ref: '#/components/schemas/InvalidAccessError'
                description: The validation error(s) or invalid access error
        '429':
          description: Rate Limit Exceeded Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/RateLimitExceededError'
        '500':
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/InternalServerError'
      security:
        - token: []
components:
  schemas:
    CustomerId:
      type:
        - string
        - 'null'
      maxLength: 255
      example: cus_GqfKXLmg61LURZhB
      description: Unique identifier for the customer, prefixed with 'cus_'
    Customer:
      type: object
      properties:
        id:
          type: string
          maxLength: 255
          example: cus_GqfKXLmg61LURZhB
          description: Unique identifier for the customer, prefixed with 'cus_'
        object:
          type: string
          example: customer
        environment:
          allOf:
            - $ref: '#/components/schemas/Environment'
            - description: >-
                The environment of the customer. Either 'sandbox' or
                'production'
        name:
          type:
            - string
            - 'null'
          minLength: 2
          example: John Doe
          description: The name of the customer
        phoneNumber:
          type: string
          description: The phone number of the customer
          example: '254712345678'
        description:
          type:
            - string
            - 'null'
          example: VIP customer with recurring payments
          description: The description of the customer
        countryCode:
          type: string
          maxLength: 2
          example: KE
          description: The country code of the customer
        isActive:
          type: boolean
          example: true
          description: Whether the customer is active
        isVerified:
          type: boolean
          example: true
          description: Whether the customer is verified
        lastActiveAt:
          type:
            - string
            - 'null'
          example: '2024-12-19T16:45:00.000Z'
          description: Timestamp when the customer was last active (ISO 8601 format)
        firstTransactionAt:
          type:
            - string
            - 'null'
          example: '2024-12-15T09:15:00.000Z'
          description: >-
            Timestamp when the customer made their first transaction (ISO 8601
            format)
        source:
          $ref: '#/components/schemas/Source'
        metadata:
          $ref: '#/components/schemas/Metadata'
        createdAt:
          type: string
          example: '2024-12-10T08:30:00.000Z'
          description: Timestamp when the customer was created (ISO 8601 format)
        updatedAt:
          type: string
          example: '2024-12-19T14:22:00.000Z'
          description: Timestamp when the customer was last updated (ISO 8601 format)
      required:
        - id
        - object
        - environment
        - name
        - phoneNumber
        - description
        - countryCode
        - isActive
        - isVerified
        - lastActiveAt
        - firstTransactionAt
        - source
        - metadata
        - createdAt
        - updatedAt
      example:
        id: cus_GqfKXLmg61LURZhB
        object: customer
        environment: sandbox
        name: John Doe
        phoneNumber: '254712345678'
        description: VIP customer with recurring payments
        metadata: {}
        countryCode: KE
        isActive: true
        isVerified: true
        firstTransactionAt: '2024-12-15T09:15:00.000Z'
        source: api
        createdAt: '2024-12-10T08:30:00.000Z'
        updatedAt: '2024-12-19T14:22:00.000Z'
        lastActiveAt: '2024-12-19T16:45:00.000Z'
    MissingApiKeyError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 401
            code:
              type: string
              description: Machine-readable error name
              example: missing_api_key
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: Missing API key in the authorization header.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Missing API Key Error
    InvalidApiKeyError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 403
            code:
              type: string
              description: Machine-readable error name
              example: invalid_api_key
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: API key is invalid.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Invalid API Key Error
    NotFoundError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 404
            code:
              type: string
              description: Machine-readable error name
              example: not_found
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: The requested endpoint does not exist.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Customer Not Found
    MethodNotAllowedError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 405
            code:
              type: string
              description: Machine-readable error name
              example: method_not_allowed
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: Method is not allowed for the requested path.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Method Not Allowed Error
    ValidationError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 422
            code:
              type: string
              description: Machine-readable error name
              example: validation_error
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: We found an error with one or more fields in the request.
            validation:
              type: array
              items:
                type: object
                properties:
                  field:
                    type: string
                    description: The name of the field that failed validation
                    example: email
                  message:
                    type: string
                    description: The validation error message for the field
                    example: Invalid email format
                required:
                  - field
                  - message
              description: List of field-specific validation issues
              example:
                - field: email
                  message: Invalid email format
                - field: age
                  message: Expected number, received string
          required:
            - status
            - code
            - message
            - validation
      required:
        - error
    InvalidAccessError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 422
          required:
            - status
        code:
          type: string
          description: Machine-readable error name
          example: invalid_access
        message:
          type: string
          x-speakeasy-error-message: true
          description: Human-readable error message
          example: >-
            The API key does not have the necessary permissions to access this
            resource.
      required:
        - error
        - code
        - message
    RateLimitExceededError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 429
            code:
              type: string
              description: Machine-readable error name
              example: rate_limit_exceeded
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: You have exceeded your request limit. Please try again later.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Rate Limit Exceeded Error
    InternalServerError:
      type: object
      properties:
        error:
          type: object
          properties:
            status:
              type: number
              description: HTTP status code of the error
              example: 500
            code:
              type: string
              description: Machine-readable error name
              example: internal_server_error
            message:
              type: string
              x-speakeasy-error-message: true
              description: Human-readable error message
              example: An unexpected error occurred.
          required:
            - status
            - code
            - message
      required:
        - error
      description: Internal Server Error
    Environment:
      type: string
      enum:
        - sandbox
        - production
      description: The environment of the transaction. Either 'sandbox' or 'production'
      example: sandbox
    Source:
      type: string
      enum:
        - api
        - dashboard
        - checkout
      example: api
      description: The source of the resource. Either 'api', 'dashboard', or 'checkout'
    Metadata:
      type: object
      additionalProperties:
        anyOf:
          - type: string
            maxLength: 500
          - type: integer
          - type: number
          - type: boolean
      description: |-
        Key-value object allowing you to store additional information.

        **Key Requirements:**
        - Must be a string
        - Maximum length of 40 characters

        **Value Types:**
        - String (maximum 500 characters)
        - Integer
        - Floating-point number
        - Boolean

        **Limits:**
        - Maximum of 50 key-value pairs
      example:
        user_preference: dark_mode
        last_login: 1640995200
        is_premium: true
        account_balance: 1250.75
        notifications_enabled: false
  securitySchemes:
    token:
      type: http
      scheme: bearer
      description: The API key to use for authentication
      x-speakeasy-example: MOFLAY_API_KEY

````