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

# Create an account

<Info>
  This endpoint requires a valid authorisation for the user. If no active authorisation exists, the request will be rejected.
  You can optionally pass the `x-teal-authorisation-id` header to specify which authorisation to use; otherwise the system will resolve a valid authorisation automatically.
  See [Authorisations](/authorisations) for more details.
</Info>


## OpenAPI

````yaml POST /accounts
openapi: 3.0.1
info:
  title: Payroll API
  description: A full flagged payroll api provided by Teal
  version: 1.0.0
servers:
  - url: https://api.sandbox.goteal.co
    description: Sandbox server for experiments
  - url: https://api.goteal.co
    description: Production server
security:
  - ApiKeyAuth: []
  - MemberBearerAuth: []
paths:
  /accounts:
    description: >-
      Account are the payroll and HR platform accesses that users link to Teal,
      providing a stream of income and employment data
    post:
      summary: Creates an account for the user e.g. a Xero account
      parameters:
        - $ref: '#/components/parameters/XAuthorisationId'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              allOf:
                - type: object
                  required:
                    - user_id
                  properties:
                    user_id:
                      type: string
                      description: The id of the user
                      example: 95a0e70b-fe02-4f47-aef9-2efff279df71
                    from:
                      type: string
                      format: date-time
                      description: Optional start date filter for payroll data retrieval
                      example: '2019-05-17T00:00:00.000Z'
                    to:
                      type: string
                      format: date-time
                      description: Optional end date filter for payroll data retrieval
                      example: '2019-05-17T00:00:00.000Z'
                - $ref: '#/components/schemas/Accounts'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                allOf:
                  - $ref: '#/components/schemas/AccountsResult'
                  - type: object
                    properties:
                      authorization_url:
                        type: string
                        description: Authrorization url for provider using OAUTH2
                        example: >-
                          https://provider/authenticate?redirect_url=https://api.teal.com/auth&state=state&scope=read
                  - type: object
                    properties:
                      mfa_method:
                        $ref: '#/components/schemas/MfaMethod'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/UnauthorizedApiKey'
components:
  parameters:
    XAuthorisationId:
      name: x-teal-authorisation-id
      in: header
      required: false
      description: >-
        Optional authorisation ID to associate with this request. If not
        provided, the system will attempt to resolve a valid authorisation for
        the user automatically.
      schema:
        type: string
        format: uuid
        example: 7f3b8c2a-1d4e-5f6g-7h8i-9j0k1l2m3n4o
  schemas:
    Accounts:
      type: object
      required:
        - payroll_provider
      properties:
        payroll_provider:
          type: string
          description: The payroll provider to use
          example: quickbooks
        user_name:
          type: string
          description: The login of the user
          example: john.smith@company.com
        password:
          type: string
          description: The password of the user
          example: very-secret-password
        extra_login_params:
          type: object
          description: |
            Optional extra login parameters required by some providers.
            Dayforce connections require `extra_login_params.company_name`.
          additionalProperties:
            type: string
          example:
            company_name: ACME Corp
    AccountsResult:
      type: object
      required:
        - payroll_provider
        - user_name
        - created_at
        - account_id
      properties:
        account_id:
          type: string
          description: The id of the account
          example: 95a0e70b-fe02-4f47-aef9-2efff279df71
        payroll_provider:
          type: string
          description: The payroll provider to use
          example: quickbooks
        user_name:
          type: string
          description: The login of the user
          example: john.smith@company.com
        status:
          type: string
          description: Status of account
          example: PENDING
        created_at:
          $ref: '#/components/schemas/Date'
        mfa_enabled:
          type: boolean
          description: Is mfa enabled for this account
        latest_pay_date:
          $ref: '#/components/schemas/Date'
          description: The latest pay date of the payroll under this account
    MfaMethod:
      type: object
      discriminator:
        propertyName: type
        mapping:
          Code:
            $ref: '#/components/schemas/CodeMfa'
          Date:
            $ref: '#/components/schemas/DateMfa'
          PasswordWithPositions:
            $ref: '#/components/schemas/PasswordWithPositions'
      oneOf:
        - $ref: '#/components/schemas/CodeMfa'
        - $ref: '#/components/schemas/DateMfa'
        - $ref: '#/components/schemas/PasswordWithPositions'
    Date:
      type: string
      format: date-time
      example: '2019-05-17T00:00:00.000Z'
    CodeMfa:
      type: object
      required:
        - type
        - source
      properties:
        type:
          type: string
          enum:
            - Code
        source:
          type: string
          enum:
            - SMS
            - EMAIL
            - AUTHENTICATOR_APP
      example:
        type: Code
        source: AUTHENTICATOR_APP
    DateMfa:
      type: object
      required:
        - type
        - format
        - message
      properties:
        type:
          type: string
          enum:
            - Date
        format:
          type: string
          example: yyyy-mm-dd
        message:
          type: string
          example: Date of birth
      example:
        type: Date
        format: yyyy-mm-dd
        message: Date of birth
    PasswordWithPositions:
      type: object
      required:
        - type
        - positions
        - message
      properties:
        type:
          type: string
          enum:
            - PasswordWithPositions
        positions:
          type: array
          items:
            type: integer
          example:
            - 1
            - 2
            - 3
        message:
          type: string
          example: Memorable word
      example:
        type: PasswordWithPositions
        positions:
          - 1
          - 2
          - 3
        message: Memorable word
    Error:
      required:
        - errors
      type: object
      properties:
        errors:
          type: array
          items:
            type: string
          description: An array of messages describing the errors
          example:
            - The request is missing the required field `name`
    Unauthorized:
      type: object
      properties:
        errors:
          type: string
          description: An array of messages describing the errors
          example:
            - No X-API-KEY header provided or wrong value
  responses:
    BadRequest:
      description: Bad request if one of the required parameters is missing
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    UnauthorizedApiKey:
      description: Unauthorized if the X-API-KEY is not provided or is wrong
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Unauthorized'
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: header
      name: X-API-KEY
    MemberBearerAuth:
      type: http
      scheme: bearer
      description: >-
        Bearer token for authentication. The token should be the one returned by
        the "/members/signin"

````