swagger: '2.0'

info:

  title: Account Applications

  description: >
  
    This API manages _applications_ to create new accounts.
    An account application coordinates the following resources necessary to complete the
    application:

     * account applicant(s) and their identity verification status
     * banking product for the new account
     * documents (required documents, uploaded instances, approvals)
     * acknowledgements the applicant has agreed to (such as terms and conditions for the banking product, electronic consent)
     * external funding account and amount (Transfer)
     * business verifications (for business accounts)
     * workflow/business process used to perform the application process
     * application approval

    These individual resources will be nested within 
    in the full representation inside the application resource,
    but are omitted in the summary application representations that are returned
    in the `applications` collection.
    Only the banking product is required to create a new account application.
    The application retains snapshots of these objects as they existed
    when the application was reviewed.

    An application may be seeded with initial data. This allows "pre-approved"
    applications from external sources. All completed applications (whether
    `approved` or `rejected`) are retained indefinitely for auditing purposes.
    Incomplete applications expire after 30 days of inactivity or a period
    specified by the financial institution in the service configuration.

    Each banking product (such as a checking account or money market account)
    has an association to an _account application workflow definition_ which
    defines the business process for opening a new account for that product.
    This workflow is a set of tasks the user must perform in order to open a new
    account for that product. This service instantiates the workflow, sets the
    `accountApplication`, `accountApplicant`, `product`, `fundingAccount`, and
    `organization` properties of the workflow instance, and starts the workflow.

    **Note:** A task in the workflow typically performs the actual account
    creation. A valid account is necessary for an _initial funding_ operation
    to occur.

    Each application maintains a `state` field which indicates the state of that
    application: `pending`, `running`, `canceled`, `expired`, `rejected`,
    `approved`.

    Note: This API uses the base path `/accountApplications` to avoid
    confusion with _software applications_.
    
  version: 0.2.0

  contact:
    name: Apiture
    url: 'https://developer.aptiture.com'
    email: api@apiture.com

  termsOfService: 'TODO: Terms of Service is TBD; need input from Legal team.'

schemes:
  - https

basePath: /accountApplications

consumes:
  - application/hal+json
  - application/json

produces:
  - application/hal+json
  - application/json

tags:
  - name: API
    description: Endpoints which describe this API.
  - name: Account Application
    description: Application for a New Banking Account
  - name: Account Application State Transitions
    description: Operations to Update the State of an Application
  - name: Configuration
    description: >-
      A set of endpoints that allows for the creation and retrieval of configuration options specific to this service

paths:
  /expiredApplications:
    post:
      operationId: expireApplication
      summary: Expire an application
      description: >-
        Update an application by adding it to the set of expired applications.
        This changes the `state` property of the application to `expired`. This
        operation is available via the `apiture:expire` link on the application
        resource, if and only if the application is eligible for the expire
        operation. The responses is the updated representation of the
        application. The `If-Match` required request header value must match the
        current entity tag value of the application.
      tags: 
        - Account Application State Transitions
      parameters:
        - $ref: '#/parameters/applicationQueryParam'
        - $ref: '#/parameters/ifMatchHeaderParam'
      responses:
        '200':
          description: >-
            OK. The operation succeeded. The application was updated and its
            `state` changed to `expired`.
          schema:
            $ref: '#/definitions/application'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update the resource.
              type: string
        '400':
          $ref: '#/responses/400ExpireApplication'
        '409':
          $ref: '#/responses/409ExpireApplicationConflict'
  /rejectedApplications:
    post:
      operationId: rejectApplication
      summary: Reject an application
      description: >-
        Update an application by adding it to the set of rejected applications.
        This changes the `state` property of the application to `rejected`. This
        operation is available via the `apiture:reject` link on the application
        resource, if and only if the application is eligible for the reject
        operation. The responses is the updated representation of the
        application. The `If-Match` required request header value must match the
        current entity tag value of the application.
      tags: 
        - Account Application State Transitions
      parameters:
        - $ref: '#/parameters/applicationQueryParam'
        - $ref: '#/parameters/ifMatchHeaderParam'
      responses:
        '200':
          description: >-
            OK. The operation succeeded. The application was updated and its
            `state` changed to `rejected`.
          schema:
            $ref: '#/definitions/application'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update the resource.
              type: string
        '400':
          $ref: '#/responses/400RejectApplication'
        '409':
          $ref: '#/responses/409RejectApplicationConflict'
  /approvedApplications:
    post:
      operationId: approveApplication
      summary: Approve an application
      description: >-
        Update an application by adding it to the set of approved applications.
        This changes the `state` property of the application to `approved`. This
        operation is available via the `apiture:approve` link on the application
        resource, if and only if the application is eligible for the approve
        operation. The responses is the updated representation of the
        application. The `If-Match` required request header value must match the
        current entity tag value of the application.
      tags: 
        - Account Application State Transitions
      parameters:
        - $ref: '#/parameters/applicationQueryParam'
        - $ref: '#/parameters/ifMatchHeaderParam'
      responses:
        '200':
          description: >-
            OK. The operation succeeded. The application was updated and its
            `state` changed to `approved`.
          schema:
            $ref: '#/definitions/application'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update the resource.
              type: string
        '400':
          $ref: '#/responses/400ApproveApplication'
        '409':
          $ref: '#/responses/409ApproveApplicationConflict'
  /canceledApplications:
    post:
      operationId: cancelApplication
      summary: Cancel an application
      description: >-
        Update an application by adding it to the set of canceled applications.
        This changes the `state` property of the application to `canceled`. This
        operation is available via the `apiture:cancel` link on the application
        resource, if and only if the application is eligible for the cancel
        operation. The responses is the updated representation of the
        application. The `If-Match` required request header value must match the
        current entity tag value of the application. 
      tags: 
        - Account Application State Transitions
      parameters:
        - $ref: '#/parameters/applicationQueryParam'
        - $ref: '#/parameters/ifMatchHeaderParam'
      responses:
        '200':
          description: >-
            OK. The operation succeeded. The application was updated and its
            `state` changed to `canceled`.
          schema:
            $ref: '#/definitions/application'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update the resource.
              type: string
        '400':
          $ref: '#/responses/400CancelApplication'
        '409':
          $ref: '#/responses/409CancelApplicationConflict'
  /runningApplications:
    post:
      operationId: startApplication
      summary: Start an application
      description: >-
        Start an application by adding it to the set of running applications.
        This changes the `state` property of the application to `running`. This
        operation is available via the `apiture:start` link on the application
        resource, if and only if the application is eligible for the start
        operation. The response is the updated representation of the
        application. The `If-Match` required request header value must match the
        current entity tag value of the application.
      parameters:
        - $ref: '#/parameters/applicationQueryParam'
        - $ref: '#/parameters/ifMatchHeaderParam'
      tags: 
        - Account Application State Transitions
      responses:
        '200':
          description: >-
            OK. The operation succeeded. The application was updated and its
            `state` changed to `running`.
          schema:
            $ref: '#/definitions/application'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update the resource.
              type: string
        '400':
          $ref: '#/responses/400StartApplication'
        '409':
          $ref: '#/responses/409StartApplicationConflict'
    get:
      summary: Return a collection of active, running account applications
      description: >-
        Return a[ paginated](https://developer.apiture.com/docs/concepts/pagination)[
        sortable](https://developer.apiture.com/docs/concepts/sorting)[
        filterable](https://developer.apiture.com/docs/concepts/filtering)[
        searchable](https://developer.apiture.com/docs/concepts/searching) collection
        of active running account applications. The
        [links](https://developer.apiture.com/docs/concepts/links) in the response
        include pagination links. This is a virtual view of all applications,
        filtered to those whose state is `running` or `blocked`
      operationId: getRunningApplications
      x-apiture-implemented: true
      tags:
        - Account Application
      parameters:
        - name: start
          in: query
          description: >-
            The zero-based index of the first account application item to
            include in this page. The default 0 denotes the beginning of the
            collection.
          type: integer
          format: int64
          default: 0
        - name: limit
          in: query
          description: >-
            The maximum number of account application representations to return
            in this page.
          type: integer
          format: int32
          default: 100
        - name: sortBy
          in: query
          type: string
          description: >-
            Optional sort criteria. See [sort criteria
            format](https://developer.apiture.com/docs/concepts/sorting), such
            as `?sortBy=field1,-field2`.
        - $ref: '#/parameters/filterQueryParam'
        - $ref: '#/parameters/qQueryParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/applications'
        '400':
          $ref: '#/responses/400'
        '422':
          $ref: '#/responses/422'
  /applications:
    get:
      summary: Return a collection of account applications
      description: >-
        Return a[ paginated](https://developer.apiture.com/docs/concepts/pagination)[
        sortable](https://developer.apiture.com/docs/concepts/sorting)[
        filterable](https://developer.apiture.com/docs/concepts/filtering)[
        searchable](https://developer.apiture.com/docs/concepts/searching) collection
        of account applications. The
        [links](https://developer.apiture.com/docs/concepts/links) in the response
        include pagination links.
        
        Not all nested objects are supported for filtering or sorting applications.
        The following fields may be used:
        `accountName`,
        `applicantName`,
        `productName`,
        `organizationName',
        `state`,
        `createdAt`,
        `completedAt`
      operationId: getApplications
      x-apiture-implemented: true
      tags:
        - Account Application
      parameters:
        - name: start
          in: query
          description: >-
            The zero-based index of the first account application item to
            include in this page. The default 0 denotes the beginning of the
            collection.
          type: integer
          format: int64
          default: 0
        - name: limit
          in: query
          description: >-
            The maximum number of account application representations to return
            in this page.
          type: integer
          format: int32
          default: 100
        - name: sortBy
          in: query
          type: string
          description: >-
            Optional sort criteria. See [sort criteria
            format](https://developer.apiture.com/docs/concepts/sorting), such
            as `?sortBy=field1,-field2`.
        - $ref: '#/parameters/filterQueryParam'
        - $ref: '#/parameters/qQueryParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/applications'
        '400':
          $ref: '#/responses/400'
        '422':
          $ref: '#/responses/422'
    post:
      summary: Create a new account application
      description: >-
        Create a new account application in the account applications
        collection. 
      operationId: createApplication
      x-apiture-implemented: true
      tags:
        - Account Application
      parameters:
        - name: application
          in: body
          description: The data necessary to create a new account application.
          required: true
          schema:
            $ref: '#/definitions/createApplication'
      responses:
        '201':
          description: Created
          schema:
            $ref: '#/definitions/application'
          headers:
            Location:
              description: >-
                The URI of the new resource. If the URI begins with / it is
                relative to the API root context. Else, it is a full URI
                starting with *`scheme`*`://host`
              type: string
              format: uri
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update the resource.
              type: string
        '400':
          $ref: '#/responses/400'
  '/applications/{applicationId}':
    get:
      summary: Fetch a representation of this account application
      description: >-
        Return a [HAL](https://developer.apiture.com/docs/concepts/hal) representation
        of this account application resource.
      operationId: getApplication
      x-apiture-implemented: true
      tags:
        - Account Application
      parameters:
        - $ref: '#/parameters/applicationIdPathParam'
        - $ref: '#/parameters/ifNoneMatchHeaderParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/application'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update this account application
                resource.
              type: string
        '304':
          $ref: '#/responses/304'
        '404':
          $ref: '#/responses/404Application'
    put:
      summary: Update this account application
      description: Perform a complete replacement of this account application.
      operationId: updateApplication
      x-apiture-implemented: true
      tags:
        - Account Application
      parameters:
        - $ref: '#/parameters/applicationIdPathParam'
        - name: application
          in: body
          required: true
          schema:
            $ref: '#/definitions/application'
        - $ref: '#/parameters/ifMatchHeaderParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/application'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update this account application
                resource.
              type: string
        '400':
          $ref: '#/responses/400'
        '404':
          $ref: '#/responses/404Application'
        '412':
          $ref: '#/responses/412'
        '422':
          $ref: '#/responses/422'
        '428':
          $ref: '#/responses/428'
    patch:
      summary: Update this account application
      description: >-
        Perform a partial update of this account application. Fields which are
        omitted are not updated. Nested `_embedded` and `_links` are ignored if
        included.
      operationId: patchApplication
      x-apiture-implemented: true
      tags:
        - Account Application
      parameters:
        - $ref: '#/parameters/applicationIdPathParam'
        - name: application
          in: body
          required: true
          schema:
            $ref: '#/definitions/application'
        - $ref: '#/parameters/ifMatchHeaderParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/application'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update this account application
                resource.
              type: string
        '400':
          $ref: '#/responses/400'
        '404':
          $ref: '#/responses/404Application'
        '412':
          $ref: '#/responses/412'
        '422':
          $ref: '#/responses/422'
        '428':
          $ref: '#/responses/428'
    delete:
      summary: Delete a pending application
      description: >-
        Delete this account application resource. An application may only be
        deleted by the user if its `state` is `pending`, or by a financial
        institution if its `state` is `expired`.
      operationId: deleteApplication
      x-apiture-implemented: true
      tags:
        - Account Application
      parameters:
        - $ref: '#/parameters/applicationIdPathParam'
      responses:
        '204':
          $ref: '#/responses/204Deleted'
        '409':
          description: >-
            Conflict. An application not be deleted by the applicant if the
            `state` is anything other than `pending`, or by the financial
            institution if the `state` is `expired`.
          schema:
            $ref: '#/definitions/errorResponse'

  /configuration:
    get:
      summary: Configuration definition for this API
      description: Returns the configuration for this API
      operationId: getConfiguration
      x-apiture-implemented: true
      tags:
        - Configuration
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/configuration'
  /configuration/groups:
    get:
      summary: Return a collection of configuration groups
      description: >-
        Return a[ paginated](http://doc.apiture.com/api/concepts/pagination)[
        sortable](http://doc.apiture.com/api/concepts/sorting)[
        filterable](http://doc.apiture.com/api/concepts/filtering)[
        searchable](http://doc.apiture.com/api/concepts/searchable) collection
        of configuration groups. The [links](http://doc.apiture.com/api/concepts/links) in
        the response include pagination links.
      operationId: getConfigurationGroups
      tags:
        - Configuration
      parameters:
        - name: start
          in: query
          description: >-
            The zero-based index of the first configuration group item to include in this
            page. The default 0 denotes the beginning of the collection.
          type: integer
          format: int64
          default: 0
        - name: limit
          in: query
          description: >-
            The maximum number of configuration group representations to return in this
            page.
          type: integer
          format: int32
          default: 100
        - name: sortBy
          in: query
          type: string
          description: >-
            Optional sort criteria. See [sort criteria
            format](http://docs.apiture.com/api/concepts/sorting#criteria), such
            as `?sortBy=field1,-field2`.
        - $ref: '#/parameters/filterQueryParam'
        - $ref: '#/parameters/qQueryParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/configurationGroups'
        '400':
          $ref: '#/responses/400'
        '422':
          $ref: '#/responses/422'
  '/configuration/groups/{groupName}':
    get:
      summary: Fetch a representation of this configuration group
      description: >-
        Return a [HAL](http://docs.apiture.com/api/concepts/hal) representation
        of this configuration group resource.
      operationId: getConfigurationGroup
      tags:
        - Configuration
      parameters:
        - $ref: '#/parameters/configurationGroupNamePathParam'
        - $ref: '#/parameters/ifNoneMatchHeaderParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/configurationGroup'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which may be
                provided in an `If-None-Match` request header for *`GET`* operations for this configuration group resource.
              type: string
        '304':
          $ref: '#/responses/304'
        '404':
          $ref: '#/responses/404ConfigurationGroup'

  '/configuration/groups/{groupName}/schema':
    get:
      summary: Fetch the schema for this configuration group
      description: >-
        Return a [HAL](http://docs.apiture.com/api/concepts/hal) representation
        of this configuration group schema resource.
      operationId: getConfigurationGroupSchema
      tags:
        - Configuration
      parameters:
        - $ref: '#/parameters/configurationGroupNamePathParam'
        - $ref: '#/parameters/ifNoneMatchHeaderParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/configurationSchema'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`*
              type: string
        '304':
          $ref: '#/responses/304'
        '404':
          $ref: '#/responses/404ConfigurationGroup'
  '/configuration/groups/{groupName}/values':
    get:
      summary: Fetch the values for the specified configuration group
      description: >-
        Return a representation of this configuration group values resource.
      operationId: getConfigurationGroupValues
      tags:
        - Configuration
      parameters:
        - $ref: '#/parameters/configurationGroupNamePathParam'
        - $ref: '#/parameters/ifNoneMatchHeaderParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/configurationValues'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`*
              type: string
        '304':
          $ref: '#/responses/304'
        '404':
          $ref: '#/responses/404ConfigurationGroup'
    put:
      summary: Update the values for the specified configuration group
      description: Perform a complete replacement of this set of values
      operationId: updateConfigurationGroupValues
      tags:
        - Configuration
      parameters:
        - $ref: '#/parameters/configurationGroupNamePathParam'
        - name: configuration group values
          in: body
          required: true
          schema:
            $ref: '#/definitions/configurationValues'
        - $ref: '#/parameters/ifMatchHeaderParam'
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/configurationSchema'
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`*
              type: string
        '400':
          $ref: '#/responses/400'
        '404':
          $ref: '#/responses/404ConfigurationGroup'
        '412':
          $ref: '#/responses/412'
        '428':
          $ref: '#/responses/428'
  '/configuration/groups/{groupName}/values/{valueName}':
    get:
      summary: Fetch a single value associated with the specified configuration group
      description: >-
        Fetch a single value associated with this configuration group.
        This provides convenient access to the map of `values` of the configuration group.
        To update a specific value,
        use `PUT /accountApplications/configuration/groups/{groupName}/values/{valueName}` (operation `updateConfigurationGroupValue`).
      operationId: getConfigurationGroupValue
      tags:
        - Configuration
      parameters:
        - $ref: '#/parameters/configurationGroupNamePathParam'
        - $ref: '#/parameters/configurationGroupValueNamePathParam'
      responses:
        '200':
          description: OK
          schema:
            type: object
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update this configuration group resource.
              type: string
        '404':
          $ref: '#/responses/404ConfigurationGroupOrValue'
    put:
      summary: Update a single value associated with the specified configuration group
      description: >-
        Update a single value associated with this configuration group.
        This provides convenient access to individual `values` of the configuration group
        as defined in the configuration group's `schema`. The request body must conform to 
        the configuration group's schema for the named `{valueName}`.
        This operation is idempotent.
        <p>
        To update a specific value, use `PUT /accountApplications/configuration/groups/{groupName}/values/{valueName}` (operation `updateConfigurationGroupValue`).
      operationId: updateConfigurationGroupValue
      tags:
        - Configuration
      parameters:
        - $ref: '#/parameters/configurationGroupNamePathParam'
        - $ref: '#/parameters/configurationGroupValueNamePathParam'
        - name: values
          in: body
          required: true
          schema:
            $ref: '#/definitions/attributes'

      responses:
        '200':
          description: OK
          schema:
            type: object
          headers:
            ETag:
              description: >-
                The `ETag` response header specifies an entity tag which must be
                provided in an `If-Match` request header for *`PUT`* or
                *`PATCH`* operations which update this configuration group resource.
              type: string
  /:
    get:
      summary: Top-level resources and operations in this API
      description: Return links to the top-level resources and operations in this API.
      operationId: getApi
      x-apiture-implemented: true
      responses:
        '200':
          description: OK
          schema:
            $ref: '#/definitions/root'
      tags:
        - API
  /apiDoc:
    get:
      summary: Return API definition document
      description: Return the OpenAPI document that describes this API.
      operationId: getApiDoc
      x-apiture-implemented: true
      produces:
        - application/json
        - application/openapi+json;version=2.0
        - application/openapi+yaml;version=2.0
      responses:
        '200':
          description: OK
          schema:
            type: object
      tags:
        - API

parameters:

  applicationQueryParam:
    name: application
    required: true
    in: query
    type: string
    description: >-
      A string which uniquely identifies an application which is to added to the
      running applications resource set. This may be the unique applicationId or
      the  URI of the application.

  applicationIdPathParam:
    name: applicationId
    description: The unique identifier of this application. This is an opaque string.
    in: path
    type: string
    required: true

  filterQueryParam:
    name: filter
    in: query
    description: >-
      Optional filter criteria. See
      [filtering](https://developer.apiture.com/docs/concepts/filtering).
    type: string

  qQueryParam:
    name: q
    in: query
    description: >-
      Optional search string. See
      [searching](https://developer.apiture.com/docs/concepts/searching).
    type: string

  ifMatchHeaderParam:
    name: If-Match
    description: >-
      The entity tag that was returned in the `ETag` response. This must match
      the current entity tag of the resource.
    in: header
    type: string
    required: true

  ifNoneMatchHeaderParam:
    name: If-None-Match
    description: >-
      The entity tag that was returned in the `ETag` response. If the resource's
      current entity tag matches, the `GET` will return 304 (Not Modified) and
      no response body, else the resource representation will be returned.
    in: header
    type: string

  configurationGroupNamePathParam:
    name: groupName
    description: The unique name of this configuration group.
    in: path
    type: string
    required: true

  configurationGroupValueNamePathParam:
    name: valueName
    description: >-
      The unique name of a value in a configuration group.
      This is the name of the value in the `schema`.
      A `{valueName}` must be a simple identifier following
      the pattern _`letter [letter | digit | '-' | '_']*`_
    in: path
    type: string
    required: true

responses:
  '304':
    description: >-
      Not Modified. The resource has not been modified since it was last
      fetched.
  '400':
    description: >-
      Bad Request. 
      The request body or one or more of the query parameters was not well
      formed.  The `_error` field in the response will contain details about the
      request error.
    schema:
      $ref: '#/definitions/errorResponse'
    x-apiture-errors:
      - emptyRequestBody
      - malformedApplicationUri  
  '412':
    description: >-
      Precondition Failed. The supplied `if-Match` header value does not match
      the most recent `ETag` response header value. The resource has changed in
      the interim.
    schema:
      $ref: '#/definitions/errorResponse'
  '422':
    description: >-
      Unprocessable Entity. One or more of the query parameters was well formed
      but otherwise invalid. The `_error` field in the response will contain
      details about the request error.
    schema:
      $ref: '#/definitions/errorResponse'
  '428':
    description: >-
      Precondition Required. The request did not include the required `if-Match`
      header. Resubmit with the operation, supplying the value of the `ETag` and
      the most recent state of the resource.
    schema:
      $ref: '#/definitions/errorResponse'
    x-apiture-errors:
      - preconditionRequired      

  400ExpireApplication:
    description: >-
      Bad Request. The application parameter was malformed or does not refer to
      an existing or accessible application.
    schema:
      $ref: '#/definitions/errorResponse'
    x-apiture-errors:
      - applicationRefNotFound

  409ExpireApplicationConflict:
    description: >-
      Conflict. The request to change the state of the application is not
      allowed. The `_error` field in the response will contain details about the
      request error.
    schema:
      $ref: '#/definitions/errorResponse'

  400RejectApplication:
    description: >-
      Bad Request. The application parameter was malformed or does not refer to
      an existing or accessible application.
    schema:
      $ref: '#/definitions/errorResponse'
    x-apiture-errors:
      - applicationRefNotFound

  409RejectApplicationConflict:
    description: >-
      Conflict. The request to change the state of the application is not
      allowed. The `_error` field in the response will contain details about the
      request error.
    schema:
      $ref: '#/definitions/errorResponse'

  400ApproveApplication:
    description: >-
      Bad Request. The application parameter was malformed or does not refer to
      an existing or accessible application.
    schema:
      $ref: '#/definitions/errorResponse'
    x-apiture-errors:
      - applicationRefNotFound

  409ApproveApplicationConflict:
    description: >-
      Conflict. The request to change the state of the application is not
      allowed. The `_error` field in the response will contain details about the
      request error.
    schema:
      $ref: '#/definitions/errorResponse'

  400CancelApplication:
    description: >-
      Bad Request. The application parameter was malformed or does not refer to
      an existing or accessible application.
    schema:
      $ref: '#/definitions/errorResponse'
    x-apiture-errors:
      - applicationRefNotFound

  409CancelApplicationConflict:
    description: >-
      Conflict. The request to change the state of the application is not
      allowed. The `_error` field in the response will contain details about the
      request error.
    schema:
      $ref: '#/definitions/errorResponse'

  400StartApplication:
    description: >-
      Bad Request. The application parameter was malformed or does not refer to
      an existing or accessible application.
    schema:
      $ref: '#/definitions/errorResponse'
    x-apiture-errors:
      - applicationRefNotFound

  409StartApplicationConflict:
    description: >-
      Conflict. The request to change the state of the application is not
      allowed. The `_error` field in the response will contain details about the
      request error.
    schema:
      $ref: '#/definitions/errorResponse'

  404Application:
    description: >-
      Not Found. There is no such application resource at the specified
      `{applicationId}`. The `_error` field in the response will contain details
      about the request error.
    schema:
      $ref: '#/definitions/errorResponse'
    x-apiture-errors:
      - applicationNotFound

  204Deleted:
    description: No Content. The resource was deleted successfully.

  404ConfigurationGroup:
    description: >-
      Not Found. There is no such configuration group resource at the specified
      `{groupName}` The `_error` field in the response will contain details
      about the request error.
    schema:
      $ref: '#/definitions/error'
    x-apiture-errors:
      - invalidGroupName
  404ConfigurationGroupOrValue:
    description: >-
      Not Found. There is either no such configuration group resource at the specified
      `{groupName}` or no such value at the specified `{valueName}`. 
      The `_error` field in the response will contain details about the request error.
    schema:
      $ref: '#/definitions/error'
    x-apiture-errors:
      - invalidValueName

definitions:
  applicationFields:
    title: Account Application Fields
    description: >-
      Common fields of the account application resource used to build other
      model schemas.
    properties:
      accountName:
        description: >-
          The name of new account.
          If initially blank, this will be initialized from the name of the first product.
        type: string
        maxLength: 128
      fundingAmount:
        description: >-
          How much money the applicant wishes to transfer from
          the funding account in order to initially fund this new account.

        allOf:
          - $ref: '#/definitions/money'
    x-apiture-traits:
      fragment: true

  applicationObjects:
    title: Application Resources
    description: >-
      Additional objects related to a new account application.
    type: object
    required:
      - products
    properties:
      products:
        description: >-
          The bank product(s) for this account.
          The first item in the array is the _primary_ product for the new account.
          The remaining optional items in the array are secondary associated products.
        type: array
        minItems: 1
        items:
          $ref: '#/definitions/summaryProduct'
      applicants:
        description: >-
          The applicant or co-applicants seeking to open the account.
          If omitted, the service will create an array with one applicant,
          based on the Contact resource associated with current user,
          and assign that contact the primary user role.
        type: array
        minItems: 1
        items:
          $ref: '#/definitions/applicant'
      organization:
        description: >-
          The optional organization for a non-personal (business)
          account.
        type: object   
        $ref: '#/definitions/organization'   
      organizationVerification:
        description: >-
          The results of verifying a business or other organization.
        type: object
        $ref: '#/definitions/businessVerifications'
      documents:
        description: >-
          An array of metadata listing zero or more documents which
          the FI reviewer must review and approve. These can be applicant
          identity verification forms, such as agovernment ID, a tax ID,
          a utility bill, articles of incorporation (for business accounts) etc.
        type: array
        items:
          $ref: '#/definitions/document'
      accountApproval:
        description: >-
          An Approval object which the reviewer can use to
          approve or reject the entire account application.
          The `apiture:approve` and `apiture:reject` links
          in the resource may be used to reject or approve
          the applications via `POST` operations (no request body).
        allOf:
          - $ref: '#/definitions/approval'
      approvals:
        description: >-
          All of the Approval objects which are associated
          with this application.
          The `apiture:approve`, `apiture:reject`, `apiture:waive`, 
          and `apiture:return` links in each Approval resource 
          may be used to approve, reject, waive, or return the approval
          via `POST` operations (no request body).
        type: array
        readOnly: true
        items:
          $ref: '#/definitions/approval'
      fundingAccount:
        description: >-
          Contact information about the applicant.
        allOf:
          - $ref: '#/definitions/transferAccount'
      newAccounts:
        description: >-
          New accounts opened via this application.
          This array has a one-to-one mapping to the `products` array.
          Use the `self` link in each item's `_links`
          to access each account.
        type: array
        items:
          $ref: '#/definitions/transferAccount'
    
  createApplication:
    title: Create Account Application
    description: >-
      Representation of the request used to create a new account application
      This does not create an _account_, just an _application_. When the
      application is completed and approved, the account will be created.
      
      The request must contain the following contents:
         * `products` - an array of one or more Product objects which determine
         the banking product for the new account(s). The first(required)
         item in
         the array is the primary account; others are optional secondary accounts in
         a product bundle. The products must be an
         _active_ internal account products that is eligible for
         opening new accounts. (`"newAccountAvailability": "available"`)
         
      These objects passed in the request may be complete object representations,
      or they may be "thin" objects with only [HAL](http://developer.apiture.com/docs/concepts/hal)
      `_links` with a `self` link containing the object URL; the application
      resource will fetch these objects.
      
      Creating an application will instantiate a workflow instance, based on a
      workflow definition that is associated with the primary banking product
      in the application. The client application should process that
      workflow instance and present any interactive tasks which are
      available to run, and continue until the workflow is done.

    allOf:
      - $ref: '#/definitions/abstractResource'
      - $ref: '#/definitions/applicationFields'
      - $ref: '#/definitions/applicationObjects'
        
    example:
      _profile: 'http://api.apiture.com/schemas/application/v1.0.0/profile.json'
      accountName: My checking account
      _links:
        'apiture:product':
          href: 'https://www.example.com/products/products/51df9a81-2cb8-4515-aad1-9543b3c4fc18'
      applicants:
        - contact:
            firstName: Elsa
            lastName: Snowqueen
            _links:
              self:
                href: 'https://www.example.com/users/user/3017d005-9910-4a8b-874b-397749353e7a'
          role:
            name: primaryUser
            label: Primary User
            _links:
              self:
                href: 'https://www.example.com/associations/roles/3ad50a2a-3129-491f-9bd9-d4cccf54b228'
      products:
        - name: Personal Savings
          _links:
            self:
              href: 'https://www.example.com/products/products/40ed6e40-cffa-4944-8d54-f9b50ed2081f'

  summaryApplication:
    title: Account Application Summary
    description: >-
      Summary representation of an account application resource in account
      applications collections. This representation normally does not contain
      any `_embedded` objects. If needed, call the `GET` operation on the item's
      `self` link to get `_embedded` objects.
    allOf:
      - $ref: '#/definitions/abstractResource'
      - $ref: '#/definitions/applicationFields'
      - type: object
        properties:
          _id:
            description: >-
              The unique identifier for this application. This is an immutable
              opaque string.
            type: string
          applicantName:
            title: Applicant Name
            description: >-
              The name of the person who started this application. This is
              derived from the applicant resource passed via the
              first applicant if present, or the current user.
            type: string
            maxLength: 128
            minLength: 1
            readOnly: true
            example: Elsa Snowqueen
          productName:
            description: >-
              The name of the banking product associated with this new account
              application. This is derived from the first product in the
              `products` array and and is imutable.
            type: string
            readOnly: true
            maxLength: 128
            minLength: 1
            example: Personal Savings
          organizationName:
            description: >-
              The name of the organization, if this is an application for a
              business acount. This will be derived from the organization
              resource, if present.
            type: string
            maxLength: 128
            minLength: 1
            readOnly: true
            example: Smith's Auto Detailing
          workflowState:
            description: >-
              The state of the embedded application workflow. This is derived
              and immutable.
            type: string
            readOnly: true
            maxLength: 16
            minLength: 1
            example: running
          state:
            description: |
              The state of the application. The values mean:
                * *`pending`* - The application is available to be started (`POST` to the `apiture:start` link on the application to start it.)
                * *`running`* - The application has started and has not completed or been canceled.
                * *`blocked`* - The application has started but is blocked; there are no available workflow tasks.
                * *`canceled`* - The application was canceled prior to completion
                * *`expired`* - The application was not completed prior to a pre-defined application lifecycle term.  For example, the FI may set a rule that all applications open longer than 30 days and not completed must be set to expired.
                * *`rejected`* - The application was completed and was rejected
                * *`approved`* - The application was completed and approved
            type: string
            enum:
              - pending
              - running
              - blocked
              - canceled
              - expired
              - rejected
              - approved
            example: pending
          createdAt:
            description: >-
              The date-time when this application was opened/created. This is in
              [RFC 3339](https://tools.ietf.org/html/rfc3339) format:
              `YYYY-MM-DDThh:mm:ss.sssZ`
            type: string
            readOnly: true
            format: date-time
          completedAt:
            description: >-
              The date-time when this application was completed and its final
              resolution was set (approved, rejected, canceled, or expired).
              This is in [RFC 3339](https://tools.ietf.org/html/rfc3339) format:
              `YYYY-MM-DDThh:mm:ss.sssZ`
            type: string
            format: date-time
            readOnly: true
    example:
      _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
      _profile: 'http://api.apiture.com/schemas/applications/application/v1.0.0/profile.json'
      applicantName: Elsa Snowqueen
      accountName: My Premiere Savings
      productName: Premiere Savings
      fundingAmount:
        value: "1500.00"
        currency: "USD"
      state: running
      workflowState: running
      createdAt: 2018-12-13T11:01:41.375Z
      _links:
        self:
          href: 'https://www.example.com/accountApplications/applications/0399abed-fd3d-4830-a88b-30f38b8a365c'
        'apiture:product':
          href: 'https://www.example.com/products/products/51df9a81-2cb8-4515-aad1-9543b3c4fc18'

  application:
    title: Account Application
    description: >-
      An application for a new account.
      The resource contains summary fields that identify
      the account applicant, the primary product, and the state of the applications.
      The nested arrays and objects contains related resources which support
      the application: `applicants` and their identity verification, related `products`, documents,
      the `organization` (for business accounts), etc.
      
      TODO: add a folder for application documents
      
    allOf:
      - $ref: '#/definitions/summaryApplication'
      - $ref: '#/definitions/applicationObjects'
      - type: object
        properties:
          _id:
            description: >-
              The unique identifier for this application. This is an immutable
              opaque string.
            type: string
          completedTaskCount:
            description: The number of visible workflow tasks which have been completed.
            type: number
            format: int32
            minimum: 0
            example: 4
            readOnly: true
          runningTaskCount:
            description: The number of visible workflow tasks which are currently running.
            type: number
            format: int32
            minimum: 0
            example: 2
            readOnly: true
          pendingTaskCount:
            description: The number of visible workflow tasks which have been completed.
            type: number
            format: int32
            minimum: 0
            example: 3
            readOnly: true
          blockedTaskCount:
            description: The number of visible workflow tasks which are blocked.
            type: number
            format: int32
            minimum: 0
            example: 0
            readOnly: true
          canceledTaskCount:
            description: The number of visible workflow tasks which have been canceled.
            type: number
            format: int32
            minimum: 0
            example: 0
            readOnly: true
    x-apiture-links:
      'apiture:expire':
        rel: 'apiture:expire'
        operationId: expireApplication
      'apiture:reject':
        rel: 'apiture:reject'
        operationId: rejectApplication
      'apiture:approve':
        rel: 'apiture:approve'
        operationId: approveApplication
      'apiture:cancel':
        rel: 'apiture:cancel'
        operationId: cancelApplication
      'apiture:start':
        rel: 'apiture:start'
        operationId: startApplication
      'apiture:product':
        rel: 'apiture:product'
        title: Product
        description: >-
          Links to the Product resource for this account application.
        verb: get
      'apiture:applicant':
        rel: 'apiture:applicant'
        title: Applicant
        description: >-
          Links to the User or Contact resource for this account
          application's applicant.
        verb: get
      'apiture:organization':
        rel: 'apiture:organization'
        title: Organization
        description: >-
          Links to the Organization resource for this account
          application's applicant, if the product is a business account.
        verb: get
      'apiture:fundingAccount':
        rel: 'apiture:fundingAccount'
        title: Funding Account
        description: >-
          Links to the accountresource for this account
          application's applicant. This may be an internal
          account or an external account.
        verb: get
      'apiture:workflow':
        rel: 'apiture:workflow'
        title: Workflow
        description: >-
          Links to the workflow instance which is run
          in order to complete the account application.
        verb: get
      'apiture:approval':
        rel: 'apiture:approval'
        title: Application Approval
        description: >-
          An Approval resource which is used to to approve or reject the application,
          should financial institution review be necessary.
        verb: get
    example:
      _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
      _profile: 'http://api.apiture.com/schemas/applications/application/v1.0.0/profile.json'
      applicantName: Elsa Snowqueen
      accountName: My Premiere Savings
      productName: Premiere Savings
      fundingAmount:
        value: "1500.00"
        currency: "USD"
      state: running
      workflowState: running
      createdAt: 2018-12-13T11:01:41.375Z
      fundingAccount:
        title: Elsa Snowqueen
        institutionName: 3rd Party Bank
        routingNumber: '021000021'
        accountNumbers:
          full: '9876543210'
          masked: '*************3210'
      organization: {}
      applicants: []
      products: []
      documents: []
      accountApproval:
        _id: 'f3e5ba25-fd3e-47f2-895e-695eaa02fff6'
        label: 'Account Approval: Premiere Savings, Elsa Snowqueen'
        state: open
        done: false
        typeName: accountApplication
        type:
          _id: bd10a515-5da8-40ec-bd4a-f60e958a297b
          name: accountApplication
          label: Account Application
          domain: https://api.apiture.com/approvals
          _links:
            self:
              href: 'https://www.example.com/approvals/approvalTypes/0399abed-fd3d-4830-a88b-30f38b8a365c'
        createdAt: '2019-12-14T06:41:35.375Z'
        _links:
          self:
            href: 'https://www.example.com/approvals/approvals/39be8d61-4570-4d2d-85e3-2f9d5e14e1a4'
      acknowledgements: []
      _links:
        self:
          href: 'https://www.example.com/accountApplications/applications/0399abed-fd3d-4830-a88b-30f38b8a365c'
        'apiture:product':
          href: 'https://www.example.com/products/products/51df9a81-2cb8-4515-aad1-9543b3c4fc18'
        'apiture:workflow':
          href: 'https://www.example.com/workflow/workflows/6d3dddd0-15c5-48f5-a2a5-f6d0d5e10121'
        'apiture:fundingAccount':
          href: 'https://www.example.comaccounts/externalAccount/0f4994e0-8ecb-4904-a589-f081bde7b8c2'
        'apiture:applicant':
          href: 'https://www.example.com/users/users/4072ed8c-755d-4879-9c2e-8f32a37e2569'
        'apiture:organization':
          href: 'https://www.example.com/organization/organization/09c56c3e-ef8f-4cfa-8d15-9c0bd2dfcdd2'
        'apiture:approval':
          href: 'https://www.example.com/approvals/approval/77f7b41b-654b-4678-b316-c6ec8413f29a'

  transferAccount:
    title: Transfer Account
    description: Summary properties of the source or  target account for a transfer.
    allOf:
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          title:
            description: >-
              The title of the account. Traditionally, this is the name of the account holder.
            maxLength: 512
            type: string
            example: John Smith
          institutionName:
            description: 'The name of the financial institution.'
            type: string
            minLength: 2
            maxLength: 128
            example: 3rd Party Bank
            readOnly: true
          routingNumber:
            description: >-
              The account routing number which identifies the financial institution.
              The full routing number and full account number are required to fully
              identify the account.
            type: string
            minLength: 9
            maxLength: 32
            example: '021000021'
            readOnly: true
          accountNumbers:
            description: The account numbers for this account
            type: object
            allOf:
              - $ref: '#/definitions/accountNumbers'
            readOnly: true
          verificationReport:
            description: >-
              A verification report is an additional layer of validation that can be
              run against a verification resource. It uses available account 
              aggregation data from an external provider to generate a pass/fail result based
              on pre-configured risk factors.
            type: object
            allOf:
              - $ref: '#/definitions/verificationReport'
            readOnly: true

  applications:
    title: Account Application Collection
    description: >-
      Collection of account applications. The items in the collection are
      ordered in the `_embedded` object with name `items`.
      The top-level `_links` object may contain pagination links (`self`, `next`, `prev`, `first`, `last`, `collection`.)
        
    allOf:
      - $ref: '#/definitions/collection'
      - type: object
        properties:
          _embedded:
            type: object
            properties:
              items:
                description: An array containing a page of account application items.
                type: array
                items:
                  $ref: '#/definitions/summaryApplication'
    example:
      _profile: >-
        http://api.apiture.com/schemas/collection/application/v0.1.0/profile.json
      start: 10
      limit: 10
      count: 67
      name: account applications
      _links:
        self:
          href: 'https://www.example.com/accountApplications/applications?start=10&limit=10'
        first:
          href: 'https://www.example.com/accountApplications/applications?start=0&limit=10'
        next:
          href: 'https://www.example.com/accountApplications/applications?start=20&limit=10'
        collection:
          href: 'https://www.example.com/accountApplications/applications'
      _embedded:
        items:
          - _profile: 'http://api.apiture.com/schemas/application/v0.1.0/profile.json'
            _links:
              self:
                href: >-
                  /accountApplications/applications/0399abed-fd3d-4830-a88b-30f38b8a365c
            _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
            name: My Personal Checking
            completedTaskCount: 1
            runningTaskCount: 0
            pendingTaskCount: 1
            blockedTaskCount: 4
            canceledTaskCount: 0
            state: pending
          - _profile: 'http://api.apiture.com/schemas/application/v0.1.0/profile.json'
            _links:
              self:
                href: >-
                  /accountApplications/applications/0399abed-fd3d-4830-a88b-30f38b8a365d
            _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
            name: 6 Month CD
            completedTaskCount: 5
            runningTaskCount: 0
            pendingTaskCount: 0
            blockedTaskCount: 0
            canceledTaskCount: 0
            state: approved


  accountNumbers:
    title: Account Numbers
    description: Different representations of an account number.
    x-apiture-reference: 'http://api.apiture.com/schemas/accounts/accountNumbers/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    properties:
      masked:
        description: >-
          A partial account number that does not contain all the
          digits of the full account number. This masked number appears in
          statements or in user experience presentation. 
          It is sufficient for a user to differentiate this account from other
          accounts they hold, but is not sufficient for
          initiating transfers, etc. The first character is
          the mask character and is repeated; this
          does not indicate that the full account number
          is the same as the mask length.
          This value is derived and immutable.
        type: string
        minLength: 9
        maxLength: 32
        readOnly: true
        example: '*************3210'
      full:
        description: >-
          The full account number. This value only appears
          when `?unmasked=true` is passed on the `GET` request. 
          Not included in the summary representation of the 
          account that is included in account collection responses.
        type: string
        minLength: 9
        maxLength: 32
        example: '9876543210'

  summaryContact:
    title: Contact
    description: >-
      Representation of a contact resource. Contact data (mailing addresses,
      phone numbers, email addresses) for an individual.
    x-apiture-reference: 'http://api.apiture.com/schemas/contacts/summaryContact/v1.0.0/schema.json'
    allOf:
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          _id:
            description: >-
              The unique identifier for this contact resource. This is an
              immutable opaque string.
            type: string
          firstName:
            description: The contact's first name (or given name)
            type: string
          middleName:
            description: The contact's middle name
            type: string
          lastName:
            description: The contact's last name (or surname)
            type: string
          preferredName:
            description: >-
              The contact's preferred name. This is how the contact's name is presented to
              the user in the interface. The default is the contact's `firstName`.
            type: string
          identification:
            description: >-
              A collection of official identifying information associated with the contact.
              This currently only supports government tax ID.
            type: array
            items:
              type: object
              required:
                - type
                - value
              properties:
                value:
                  description: >-
                    The value of this form of identification (the tax ID as a string, for example)
                  type: string
                type:
                  description: >-
                    The type of this form of identification. Supported types
                    include taxId and passportNumber.
                  type: string
                  enum:
                    - taxId
                    - passportNumber
                expiration:
                  description: >-
                    The date when the form of identification expires.
                  type: string
                  format: date
          addresses:
            description: An array of postal mailing addresses for this contact.
            type: array
            items:
              type: object
              $ref: '#/definitions/address'
          yearsAtAddress:
            description: The contact's years at current home address
            type: string
          mailingDifferentAddress:
            description: The contact is handling a different address for mailing
            type: boolean
          phones:
            description: A collection of phone numbers associated with the contact.
            type: array
            items:
              type: object
              properties:
                type:
                  description: >-
                    The type of phone number this represents.
                  type: string
                  enum:
                    - home
                    - work
                    - mobile
                    - other
                number:
                  description: >-
                    The phone number, as a string.
                  type: string
                  example: 555-555-5555
          emailAddresses:
            description: >-
              An array of email addresses associated with the contact.
              The first item, if present, is the default (preferred)
              contact email.
            type: array
            items:
              type: string
              format: email
          kycAnswers:
            description: >-
              An object that contains the answers to kyc questions. 
              These will be toggle-able and configurable in the future.
            type: object
          birthdate:
            description: The contact's birth date in `YYYY-MM-DD` format.
            type: string
            format: date
          citizenship:
            description: The contact's citizenship or nationality status.
            type: array
            items:
              type: object
              required:
                - countryCode
                - state
              properties:
                countryCode:
                  description: The ISO 3166-1 country code for the contact's citizenship.
                  type: string
                  minLength: 2
                  maxLength: 2
                state:
                  description: The contact's citizenship status (values TBD).
                  type: string
                  enum:
                    - citizen
                    - other
          occupation:
            type: string
          state:
            description: The state of this contact.
            type: string
            enum:
              - inactive
              - active
              - merged
              - removed
    example:
      _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
      _profile: 'http://api.apiture.com/schemas/contacts/summaryContact/v0.1.0/profile.json'
      firstName: John
      middleName: Daniel
      lastName: Smith
      preferredName: John
      identification:
        - value: 111-11-1111
          type: taxId
      emailAddresses:
        - api@apiture.com
        - support@apiture.com
      phones:
        - type: home
          number: '(555) 555-5555'
        - type: mobile
          number: '(999) 555-5555'
      birthdate: '1974-10-27'
      citizenship:
        - countryCode: US
          status: citizen
      occupation: Software Engineer
      addresses:
        - type: home
          addressLine1: 555 N Front Street
          addressLine2: Suite 5555
          city: Wilmington
          regionCode: NC
          postalCode: 28401-5405
          countryCode: US
        - type: work
          addressLine1: 123 S 3rd Street
          addressLine2: Apt 42
          city: Wilmington
          regionCode: NC
          postalCode: 28411-5405
          countryCode: US
      yearsAtAddress: 3
      mailingDifferentAddress: false
      kycAnswers:
        citizen: true
        permanentResident: true
        w9Withholdings: false
        employmentStatus: employed
        occupation: Software Engineer
        foreignPoliticalFigure: false
        countryPoliticalFigure: N/A
        familyOfPoliticalFigure: false
      state: active
      _links:
        self:
          href: 'https://www.example.com/contacts/contacts/0399abed-fd3d-4830-a88b-30f38b8a365c'

  address:
    title: Address
    description: A postal address.
    type: object
    properties:
      type:
        type: string
        enum:
          - home
          - work
          - school
          - other
      label:
        description: >-
          A text label, suitable for presentation to the end user.
          This is also used if `type` is `other`.
        type: string
      addressLine1:
        description: >-
          The first street address line of the address,
          normally a house number and street name.
        type: string
      addressLine2:
        description: >-
          The optional second street address line of the address.
        type: string
      city:
        description: >-
          The name of the city or municipality.
        type: string
      regionCode:
        description: >-
          The mailing address region code, such as state in the US,
          or a province in Canada.
        type: string
        example: NC
      postalCode:
        description: >-
          The mailing address postal code, such as a US Zip or Zip+4 code,
          or a Canadian postal code.
        type: string
        example: 28401-5405
      countryCode:
        description: The ISO 3166-1 country code.
        type: string
        minLength: 2
        maxLength: 2
      addressId:
        description: Identifier for address in finxact
    example:
      type: home
      addressLine1: 555 N Front Street
      addressLine2: Suite 5555
      city: Wilmington
      regionCode: NC
      postalCode: 28401-5405
      countryCode: US

  contactVerification:
    title: Contact Verification
    description: Identity verification results for a Contact (a person).
    allOf:
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          verifications:
            type: array
            items:
              properties:
                _links:
                  $ref: '#/definitions/links'
                state:
                  type: string
                  enum:
                    - passed
                    - failed
                verifiedAt:
                  description: >-
                    The date-time when the verification occurred, in
                    [RFC 3339](https://tools.ietf.org/html/rfc3339) format
                    (`YYYY-MM-DDThh:mm:ss.sssZ`)
                  type: string
                  format: date-time
                  example: '2019-01-12T10:19:41Z'
    example:
      _links:
        'apiture:contact':
          href: /contacts/contacts/6da5ccc7-727a-4256-bdd4-74023ae349c3
      verifications:
        - type: fraudRiskReport
          _links:
            self:
              href: /identity/fraudRiskReports/c6dbc32f-e0eb-4947-9819-c691bb9164a5
          state: passed
          verifiedAt: '2019-01-12T10:15:17Z'
        - type: quiz
          _links:
            self:
              href: /identity/quizzes/73be83af-9e64-4214-8e90-76da43610b31
          state: passed
          verifiedAt: '2019-01-12T10:19:41Z'

  acknowledgement:
    title: Acknowlegement
    description: >-
      A document which the user has read and accepted/acknowledged.
    type: object
    properties:
      documentUri:
        title: Document URI
        description: The URI of the document that the user viewed.
        type: string
        example: 'https://www.example.com/vault/documents/7e27f43e-8b14-4f71-8065-57f364347aab'
      locale:
        title: User Locale (aa_BB)
        description: >-
          Optional locale of user. This is in HTTP Accept-Language format such as `"en_US"` or `"en_MX"`.
        type: string
        example: en_US
      accepted:
        title: Accept the Document
        description: >-
          A boolean value that indicates whether or not the user has accepted
          the document.
        type: boolean
      acceptedAt:
        title: Date/Time Accepted
        description: >-
          A time stamp indicating the date and time when the user accepted
          the document. This is an [RFC 3339](https://tools.ietf.org/html/rfc3339) formatted date time string.
        type: string
        format: date-time
        example: '2019-11-14T07:45:52.375Z'

  money:
    title: Money
    description: An amount of money in a specific currency.
    x-apiture-reference: 'http://api.apiture.com/schemas/commonFin/money/v1.0.0/schema.json'
    properties:
      value:
        description: >-
          The net monetary value. A negative amount denotes a debit; a positive
          amount a credit. The numeric value is represented as a string so that
          it can be exact with no loss of precision.
        example: '3456.78'
        type: string
      currency:
        description: >-
          The [ISO 4217 currency code](https://en.wikipedia.org/wiki/ISO_4217)
          for this monetary value. This is always upper case ASCII. TODO: ISO
          4217 defines three-character codes. However, ISO 4217 does not account
          for cryptocurrencies. Of note, DASH uses 4 characters.
        type: string
        minLength: 3
        maxLength: 3
        example: "USD"

  applicant:
    title: Applicant
    description: >-
      An applicant for a new account. 
    properties:
      contact:
        description: >-
          A Contact object representing an individual to user.
        type: object
        allOf:
          - $ref: "#/definitions/summaryContact"
      role:
        description: >-
          The role the user has on the account.
          This is a Role resource from the Associations API;
          it must be a bank account role. The default is determined
          by the number of applicants and the type of account (personal
          vs. business.)
        type: object
        allOf:
          - $ref: "#/definitions/role"
      verification:
        description: >-
          The verification status of the user or contact.
        type: object
        allOf:
          - $ref: '#/definitions/contactVerification'
      acknowledgements:
        description: >-
          An array of documents which the the applicant has
          accepted, such as terms of use, electronic consent.
        type: array
        items:
          $ref: '#/definitions/acknowledgement'
      fraudReport: 
        description: >-
          The fraud risk report for the applicant. 
        type: object
        allOf:
          - $ref: "#/definitions/fraudRiskReport"
      verified:
        description: >-
          `true` if and only if the applicant has been verified.
        type: boolean
        readOnly: true
      verificationToken:
        description: >-
          A secure token that contains identity verification data about a given contact 
          including their verified status.  The verified property in this applicant schema 
          is derived from the Boolean status embedded in this token.  The data contained in 
          this token is derived from the results of any identity verification service 
          operations previously performed on the contact.
        type: string
        readOnly: true

  role:
    title: Role
    description: >-
      A role that a user or contact holds relative to an account,
      such as _Primary User_, _Authorized Signer_, _Power of Attorney_.
    x-apiture-reference: 'http://api.apiture.com/schemas/associations/role/v1.0.0/schema.json'
    allOf:
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          _id:
            description: >-
              The unique identifier for this role resource. This is an immutable
              opaque string.
            type: string
          name:
            description: >-
              The name of this role, for identification purposes,
              such as `owner`, `beneficiary`, `authorizedSigner`.
              Some roles have well-known uses in the platform.
            type: string
            maxLength: 128
            minLength: 1
            example: owner
          label:
            description: >-
              The text label for this role, for use in human presentation. This field may be localized.
            type: string
            maxLength: 128
            minLength: 1
            example: 'Primary User'
          description:
            description: >-
              A fuller description of this role. This field may be localized.
            type: string
            maxLength: 4096
            minLength: 1
          createdAt:
            description: >-
              The date-time when the role was created. This is in
              [RFC 3339](https://tools.ietf.org/html/rfc3339) format, UTC. 
              This is derived and immutable.
            type: string
            format: date-time
            readOnly: true

  document:
    title: Document
    description: >-
       An document, submitted by the account application, which is
       pending review: approval or rejection.
    type: object
    required:
      - documentUri
      - type
      - approval
    properties:
      documentUri:
        description: >-
          A URI of the document which the applicant has uploaded and
          which is to be reviewed and approved or rejected.
          The document must resides in the document storage system
          (this is the URI of a document in the Vault API).
        type: string
      contentType:
        description: >-
          The [media type](https://tools.ietf.org/html/rfc6838) for this file. 
          For text documents, the content type should include the text encoding; if omitted,
          the encoding type is assumed to be utf-8.
        type: string
        example: 'application/pdf'
      type:
        description: >-
          The document type as determined by the business use case. Unlike the
          contentType, this indicates what the document content represents (such
          as a `processedCheckImage`,  `mobileCheckDepositImageFront`, etc.)
        type: string
        example: "governmentId"
      approval:
        description: >-
          An Approval object which the reviewer can use to
          approve or reject this document.
          The `apiture:approve`,  `apiture:return`, `apiture:reject` and `apiture:waive` links
          in the resource may be used to approve, return, reject, or waive
          the document review via `POST` operations (no request body)
          to the `href` URL in the respective links.
        type: object
        allOf:
          - $ref: '#/definitions/approval'
  
  productTypeFields:
    title: Product Type Fields
    description: Common fields of the product type resource.
    x-apiture-reference: 'http://api.apiture.com/schemas/products/productTypeFields/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    allOf:
      - $ref: '#/definitions/prodState'
      - type: object
        properties:
          name:
            description: The name of this product type.
            type: string
            maxLength: 128
            minLength: 1
          label:
            description: The text label for this product type. This field may be localized.
            type: string
            maxLength: 128
            minLength: 1
          description:
            description: >-
              A fuller description of this product type. This field may be
              localized. 
              The content is processed as 
              [Github Flavored Markdown](https://help.github.com/articles/basic-writing-and-formatting-syntax/)
              and thus supports rich text.
            type: string
            maxLength: 4096
            minLength: 1
            format: markdown
          subtype:
            description: >-
              Indicates if this is a subtype. This is a derived, immutable property, based
              on whether the product type was created with a link to a parent
              type. See also the *`apiture:parent`* link on the `productSubtype`
              schema.
            type: boolean
          subtypeCount:
            description: >-
              `0` if this type does not have subtypes; otherwise this holds the
              indicated number of direct subtypes. 
              This is a derived, immutable property.
              See also the *`apiture:children`* link on the `productSubtype` schema.
            type: number
            format: integer
            minimum: 0

  prodState:
    title: State of a Product or Product Type
    description: >-
      The state of a product or type
      
        * *`pending`* is a new product or type that is not yet
        active. Only `pending` items may be deleted. This is the default state.
        * *`active`* is an item that is in use or available for use.
        * *`inactive`* is an item that is no longer in use or available for
        use. An item cannot be changed to `inactive` if any other resource
        is using it. For example, a product type may not be set to
        `inactive` if any active product is of that type; a product may not
        be set to `inactive` if there are any active accounts for that
        product.
        * *`removed`* Removed and archived. Removed items are not eligible to be activated.
        When an account is removed, it's name is changed so that the name
        may be used for new products or product types.
        
        The `state` property is immutable and derived and may not be changed
        via the `PUT` or `PATCH` operations.
        
        To change the state of a product or product type, use the `POST` operation
        using the `apiture:activate`, `apiture:deactivate` or `apiture:remove`
        links on the resource.
    x-apiture-reference: 'http://api.apiture.com/schemas/products/prodState/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    properties:
      state:
        type: string
        enum:
          - pending
          - active
          - inactive
          - removed
        default: pending

  summaryProductType:
    title: Product Type Summary
    description: >-
      Summary representation of a product type resource in product types
      collections. This representation normally does not contain any `_embedded`
      objects. If needed, call the `GET` operation on the item's `self` link to
      get `_embedded` objects. This representation omits the `attributes`
      of the full representation.
    x-apiture-reference: 'http://api.apiture.com/schemas/products/summaryProductType/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    allOf:
      - $ref: '#/definitions/productTypeFields'
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          _id:
            description: >-
              The unique identifier for this product type resource. This is an
              opaque string.
            type: string
    example:
      _id: eccb54ed-0f0a-443b-9f2e-32d5b8f4371c
      _profile: 'https://api.apiture.com/schemas/products/productType/v0.3.0/profile.json'
      _links:
        self:
          href: 'https://www.example.com/products/productTypes/eccb54ed-0f0a-443b-9f2e-32d5b8f4371c'
        'apiture:parent':
          href: 'https://www.example.com/products/productTypes/4ea6fe4e-405c-4d71-93e3-ad637b5cab2d'
      name: Demand Deposit with Interest
      label: Demand Deposit with Interest
      description: A demand deposit checking account with interest.
      state: active
      subtype: true
      subtypeCount: 0

  productType:
    title: Product Type
    description: >-
      Representation of a product type resource. The response may include links
      to related resources, in addition to the normal *`self`* link:
        * *`apiture:parent`* If this type is a subtype, this link will be present; it links to the parent type.
        * *`apiture:children`* If this type has subtypes, this link will be present; it links to the collection of _direct_ subtypes of this type.
        * *`apiture:products`* is a link to a filtered collection of
        products which use this product type.
        * *`apiture:activate`* use `POST` to this link's `href` to activate ths current
        product type. This link only exists if the product type may be activated.
        * *`apiture:deactivate`* use `POST` to this link's `href` to deactivate ths current
        product type. This link only exists if the product type may be deactivated.
        * *`apiture:remove`* use `POST` to this link's `href` to remove ths current
        product type. This link only exists if the product type may be removed.
      Additionally, if the type is a subtype, the `_embedded` resource will
      contain the parent type.
    x-apiture-reference: 'http://api.apiture.com/schemas/products/productType/v1.0.0/schema.json'
    allOf:
      - $ref: '#/definitions/summaryProductType'
      - type: object
        properties:
          attributes:
            type: object
            description: >-
              An optional map of name/value pairs which provide additional
              metadata about the product type.
          createdAt:
            description: >-
              The date-time when this product type was created. This value is
              derived and immutable.
            type: string
            format: date-time
          _embedded:
            description: >-
              Embedded resources for this product type. This may contain the parent
              type, if any. _embedded may not appear if there are no embedded
              resources.
            type: object
            properties:
              parent:
                description: 'In subtypes, this is the parent type.'
                allOf:
                  - $ref: '#/definitions/summaryProductType'
    example:
      _id: eccb54ed-0f0a-443b-9f2e-32d5b8f4371c
      _profile: 'https://api.apiture.com/schemas/products/productType/v0.3.0/profile.json'
      _links:
        self:
          href: 'https://www.example.com/products/productTypes/eccb54ed-0f0a-443b-9f2e-32d5b8f4371c'
        'apiture:parent':
          href: 'https://www.example.com/products/productTypes/4ea6fe4e-405c-4d71-93e3-ad637b5cab2d'
      _embedded:
        parent:
          _id: 4ea6fe4e-405c-4d71-93e3-ad637b5cab2d
          _profile: 'https://api.apiture.com/schemas/products/productType/v0.3.0/profile.json'
          name: Demand Deposit
          label: Demand Deposit
          description: A demand deposit checking account.
          state: active
          subtype: false
          subtypeCount: 1
          _links:
            self:
              href: 'https://www.example.com/products/productTypes/4ea6fe4e-405c-4d71-93e3-ad637b5cab2d'
      name: Demand Deposit with interest
      label: Demand Deposit with Interest
      description: A demand deposit checking account with interest.
      state: active
      subtype: true
      subtypeCount: 0
    properties:
      createdAt:
        description: >-
          The date-time when this product type was created. This value is
          derived and immutable.
        type: string
        format: date-time
      _embedded:
        description: >-
          Embedded resources for this product type. This may contain the parent
          type, if any. _embedded may not appear if there are no embedded
          resources.
        properties:
          parent:
            description: 'In subtypes, this is the parent type.'
            allOf:
              - $ref: '#/definitions/productType'


  fee:
    title: Fee
    description: Fees that are attached to accounts of this product.
    type: object
    x-apiture-reference: 'http://api.apiture.com/schemas/products/fee/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    properties:
      type:
        description: >-
          The fee type.

            * *`service`* - servicing fee
            * *`minimumBalance`* - average monthly account balance is
            less than the product's `constraints.minimumBalance`
            * *`overdraft`* - fee assessed if user overdrafts (balance drops below the minimum balance)
            * *`returnedCheck`* - check is presented when the account has insufficient funds.
            * *`statementHardCopy`* - administration and postage to send physical copy of statement
            * *`atm`* - fee for Automatic Teller Machine (ATM) use outside of the financial institutions ATM network
            * *`foreignTransactions`* - fee due to foreign transactions
            * *`earlyClosing`* - if the acct is closed _early_  as determined by the financial institution.
            * *`earlyWithdrawal`* - if a user withdraws funds from CD before the maturity date
            * *`other`* - Other fees, as described in the fee description
        type: string
        enum:
          - service
          - minimumBalance
          - overdraft
          - returnedCheck
          - statementHardCopy
          - atm
          - foreignTransactions
          - earlyClosing
          - earlyWithdrawal
          - other

      period:
        description: >-
          The period at which the fee is assessed. If omitted, the fee
          is assessed per transaction.
          <p>
          This value is an [ISO 8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) string of
          the form `P[n]Y[n]M[n]D` to specify the fee period in the number of years/months/weeks/days.
          For example, the values `P1d`, `P1W`, `P2W`, `P1M`, `P0.25Y`, `P0.5Y`, `P1Y` indicate a term of
          daily, weekly, by-weekly, monthly, quarterly, biannually, and annually, respectively,
          (although other periods may be allowed.)
        type: string
        example: P1M
      description:
        description: >-
          A description of the fee and its structure and period.
        type: string
      structure:
        description: >-
          The fee structure: fixed fee, variable fee, or other.
          For example, the `service` fee or `atm` may be `fixed`
          (such as `"amount" : "2.00"`)
          but the `foreignTransactions` fee may be `variable`.
        type: string
        enum:
          - unknown
          - variable
          - fixed
      amount:
        description: >-
          The amount of the (fixed) fee, in the product's `currency`.
        type: string
        example: '1.00'

  transactionTypes:
    title: Transaction Types
    description: An array which lists which transaction types are allowed for an account.
    x-apiture-reference: 'http://api.apiture.com/schemas/products/transactionTypes/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    type: array
    items:
      $ref: '#/definitions/transactionType'

  transactionType:
    title: Transaction Type
    description: >-
      A string which defines a transaction type allowed for an account.
      
        * *`credit`* : Credits may be posted to this account, such as transfer funds _to_ this external account.
        * *`debit`* : Debits may be posted to this account, such as transfer funds _from_ this external account.
    x-apiture-reference: 'http://api.apiture.com/schemas/products/transactionType/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    type: string
    enum:
      - debit
      - credit

  productFields:
    title: Product Fields
    description: Common fields of the product resource.
    x-apiture-reference: 'http://api.apiture.com/schemas/products/productFields/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    allOf:
      - $ref: '#/definitions/prodState'
      - type: object
        properties:
          name:
            description: The name of this product.
            type: string
            maxLength: 128
            minLength: 1
          label:
            description: The text label for this product. This field may be localized.
            type: string
            maxLength: 128
            minLength: 1
          description:
            description: >-
              A fuller description of this product. This field may be localized.
              The content is processed as 
              [Github Flavored Markdown](https://help.github.com/articles/basic-writing-and-formatting-syntax/)
              and thus supports rich text.
            type: string
            maxLength: 4096
            minLength: 1
            format: markdown
          code:
            description: >-
              The unique product code for this product, normally defined by the
              underlying banking core. The `code` cannot be changed once the
              `state` is beyond `pending`.
            type: string
            maxLength: 64
          newAccountAvailability:
            description: >-
              Indicates if the product is available for opening new accounts.

                * *`available`* means the product may be selected for a new account application.
                * *`notAvailable`* means the product may *not* be selected for a new account application.

              The default is `available`. Note that clients must check both the
              product `state` and the `newAccountAvailability` when listing
              products for new account opening. The `?openable=true` query
              parameter on `/accounts` combines these.
              
              **TODO** This field will not be directly mutable in the future;
              so that changing availability does not require updating the product
              and creating a new revision. Instead, this field will be _derived_,
              based on the product's existence in the `unlockedProducts` collection.
            type: string
            enum:
              - available
              - notAvailable
          category:
            description: >-
              The product category name.
            type: string
          rate:
            description: >-
              The interest rate for this product.
            allOf:
              - $ref: '#/definitions/rate'
          revision:
            description: >-
              The revision string for this product.
              This property derived and immutable.
            type: string

  summaryProduct:
    title: Product Summary
    description: >-
      Summary representation of a product resource in products collections. This
      representation normally does not contain any `_embedded` objects. If
      needed, call the `GET` operation on the item's `self` link to get
      `_embedded` objects. This representation omits the `attributes`
      of the full representation.
    x-apiture-reference: 'http://api.apiture.com/schemas/products/summaryProduct/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    allOf:
      - $ref: '#/definitions/abstractResource'
      - $ref: '#/definitions/productFields'
      - $ref: '#/definitions/revisionEffectiveInterval'
      - type: object
        properties:
          _id:
            description: >-
              The unique identifier for this product resource. This is an
              immutable opaque string.
            type: string
          type:
            description: >-
              The product type name, which is derived from the linked product
              type.
              The product category name
            type: string
          subtype:
            description: >-
              The product subtype name, which is derived from the linked product
              subtype.
              This is a derived, immutable property.
            type: string
    example:
      _id: a6459cdf-543e-46df-887b-ac5378ee9acd
      _profile: 'https://api.apiture.com/schemas/products/product/v0.3.0/profile.json'
      _links:
        self:
          href: 'https://www.example.com/products/products/a6459cdf-543e-46df-887b-ac5378ee9acd'
        'apiture:productType':
          href: 'https://www.example.com/products/productTypes/4d4242ed-eb8d-46ca-bc3c-13e1f82337c8'
        'apiture:productSubtype':
          href: 'https://www.example.com/products/productTypes/fa4f2335-3306-4721-b74c-8ec0c77823e9'
      name: Premiere Checking
      label: Premiere Checking
      description: A premiere demand deposit checking account for business use.
      state: active
      type: Demand Deposit
      subtype: Demand Deposit with Interest
      newAccountAvailability: available
      revision: '2019-04-25T07:56:46.375Z'
      _embedded: {}

  revisionEffectiveInterval:
    title: Revision Effective Time Interval
    description: >-
      Time interval when a resource revision was active.
      This schema is used when composing other schemas.
      <p>
      **Note**: This schema should be moved to common-models.
    type: object
    x-apiture-reference: 'http://api.apiture.com/schemas/common/revisionEffectiveInterval/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    properties:
      effectiveStartAt:
        description: >-
          The date-time when this revision was created and become effective.
          This is a string in [RFC 3339](https://tools.ietf.org/html/rfc3339) format: `YYYY-MM-DDThh:mm:ss.sssZ`.
          This field is immutable.
        type: string
        format: date-time
      effectiveEndAt:
        description: >-
          The date-time when the another revision became effective and this revision ceased being effective.
          This is a string in [RFC 3339](https://tools.ietf.org/html/rfc3339) format: `YYYY-MM-DDThh:mm:ss.sssZ`.
          This field is immutable and is not present until the revision is no longer active.
          If present in a PUT or PATCH, this date (not the current
          date-time) will be used for the revision ID and the `effectiveStartAt` of the next revision,
          but the date must be between the revision's `effectiveStartAt` and 
          the current date-time.
        type: string
        format: date-time

  rate:
    title: Rate
    description: >-
      The interest rate of the account. For deposit accounts, this is the rate
      of return; for loan accounts, this is the interest rate charged on
      balances. Rates can be absolute, such as "1.40" to indicate 1.4%, which is
      expressed as  `{ "rate" : "1.40" }`. or relative to a benchmark, such as
      U.S. Prime Rate + 0.5% which is expressed as `{ "benchmark" : "prime",
      "rate" : "0.50" }`.
    x-apiture-reference: 'http://api.apiture.com/schemas/products/rate/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    properties:
      value:
        description: >-
          The rate, expressed as an decimal percentage string in order to
          represent the rate exactly. This number must have 2 to four decimal
          points, i.e. '2.00' or '0.50' or '1.015', but not `2` or `.5`.
          (Regular expression pattern: `-?\d{1,3}+\.\d{2,4}`)
        type: string
        example: '1.40'
      benchmark:
        description: >-
          An optional base benchmark that the rate is relative to. If omitted,
          the rate is fixed. Otherwise the rate is added to the benchmark rate.
          Values may be (but are not limited to):
           * *`primeUS`* - the [U.S. Prime rate](https://en.wikipedia.org/wiki/Prime_rate)
           * *`treasuryUS`* - The [U.S. Treasury rate](https://www.treasury.gov/resource-center/data-chart-center/interest-rates/Pages/TextView.aspx?data=yieldAll)
           * *`libor`* - the [London Inter-bank Offered Rates rate](https://en.wikipedia.org/wiki/Libor)
        type: string
        example: prime
      compoundPeriod:
        description: >-
          The period at which interest compounds.  <p> This value is an [ISO
          8601 duration](https://en.wikipedia.org/wiki/ISO_8601#Durations)
          string of the form `P[n]Y[n]M[n]D` to specify the term in the number
          of years/months/days. The default is `"P0D"` (continuous).
        type: string
        example: P7D
      accrualType:
        description: Indicates how interest is accrued.
        type: string
        enum:
          - compounding
          - simple
          - frontLoading
      adjustmentPeriod:
        description: >-
          The period at which the rate is adjusted or recomputed to account for
          differences in the benchmark rate. <p> This value is an [ISO 8601
          duration](https://en.wikipedia.org/wiki/ISO_8601#Durations) string of
          the form `P[n]Y[n]M[n]D` to specify the term in the number of
          years/months/days; The default is `"P1D"` (daily).
        type: string
        example: P1D
      type:
        description: The interest rate type.
        type: string
        allOf:
          - $ref: '#/definitions/interestRateType'
    example:
      value: '1.40'
      type: apr

  interestRateType:
    title: Interest Rate Type
    description: >-
      The rate type. The rate type may not be changed once it is set at product
      creation.
      Rate types are:
        * *`apr`* - annual percentage rate
        * *`apy`* - annual percentage yield. This applies for Demand
            Deposit Accounts (DDA), Money Market Accounts (MMA), 
            Certificate of Deposit Accounts (CDA), Savings Deposit
            Accounts (SDA)
    x-apiture-reference: 'http://api.apiture.com/schemas/product/rates/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    type: string
    enum:
      - apr
      - apy
    example: apr


  approvalFields:
    title: Approval Fields
    description: >-
      Common fields of the approval resource used to build other model schemas.
    x-apiture-reference: 'http://api.apiture.com/schemas/approvals/approvalFields/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    properties:
      label:
        description: The approval's common name.  If ommitted on create request, this will default to the label of the Approval Type.
        type: string
      description:
        description: The approval's description.  If ommitted on create request, this will default to the description of the Approval Type.
        type: string
      state:
        description: >-
          The approval's state.

            * **`open`** Created but pending input subject to approval
            * **`submitted`** Pending review by approver
            * **`approved`** Approval granted
            * **`rejected`** Approval denied
            * **`waived`** Approval forgiven
            * **`returned`** Approver returns approval for modification
            * **`canceled`** Approval request withdrawn


          This is an immutable and derived property. It's value can only be changed by using the corresponding `POST` operations,
          `submitApproval`, `approveApproval`, `rejectApproval`, `waiveApproval`, `returnApproval`, and `cancelApproval`.

        type: string
        enum:
          - open
          - submitted
          - approved
          - rejected
          - waived
          - returned
          - canceled
        default: open
      done:
        description: >-
          Inferred done flag.  If `done` is true, the approval is in a
          terminal state and may no longer be acted upon.  Done states
          include `canceled`, `approved`, `waived` or `rejected`. 
        type: boolean
      typeName:
        description: The name of the Approval Type.  This field is immutable and derived from the name of the Approval Type.
        type: string
      reviewedBy:
        description: The id of the User that reviewed the approval.
        type: string
      reviewedAt:
        description: The date-time when the approval was reviewed.
        type: string
        format: date-time
    example:
      state: active
      done: true
      label: Government Issued ID
      typeName: governmentId
      description: A document that identifies a user
      reviewedBy: /users/users/0399abed-fd3d-4830-a88b-30f38b8a365c
      reviewedAt: '2019-04-17T10:12:58.375Z'

  summaryApproval:
    title: Approval Summary
    description: >-
      Summary representation of an approval resource in approvals collections. This
      representation normally does not contain any `_embedded` objects. If
      needed, call the `GET` operation on the item's `self` link to get
      `_embedded` objects.
    x-apiture-reference: 'http://api.apiture.com/schemas/approvals/summaryApproval/v1.0.0/schema.json'
    allOf:
      - $ref: '#/definitions/abstractResource'
      - $ref: '#/definitions/approvalFields'
      - type: object
        properties:
          _id:
            description: >-
              The unique identifier for this approval resource. This is an
              immutable opaque string.
            type: string
    example:
      _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
      _profile: 'http://api.apiture.com/schemas/approvals/approvals/v1.0.0/profile.json'
      _links:
        self:
          href: 'https://www.example.com/approvals/approvals/0399abed-fd3d-4830-a88b-30f38b8a365c'

  approval:
    title: Approval
    description: >-
      An approval represents the _review_ of
      some process, activity or resource, such as a document or an application.
      The state of the approval is recorded in its `state` property. The
      target of the approval is in the link named `apiture:target`;
      see the _Create Approval_ schema and `createApproval` operation.

      Links on an approval convey which state transitions are available.
      These links are:

        * **`apiture:approve`** -- mark the review request as approved
        * **`apiture:reject`** -- to reject the approval request
        * **`apiture:waive`** -- to waive the approval requirements. For example, rather than requiring a specific
        identity verification document to be approved, waiving the requirement means the document does not have to
        be provided.
        * **`apiture:return`** -- to return the request so the client can update the request or resource, then resubmit the request for approval
        * **`apiture:submit`** -- to submit a new request for appoval, or resubmit a request after it has been returned
        * **`apiture:cancel`** -- to cancel the request for review/approval
        
      The client should use `POST` to invoke these operations, using the `href`
      on the named link object. No request body is used on these operations.

      The absence of a link indicates that the particular state
      transition is not available at that time or that the caller
      is not authorized to make the change. For example, a user
      may lack permissions to approve a wire transfer they submitted.
    x-apiture-reference: 'http://api.apiture.com/schemas/approvals/approval/v1.0.0/schema.json'
    allOf:
      - $ref: '#/definitions/summaryApproval'
      - type: object
        properties:
          attributes:
            type: object
            description: >-
              An optional map of name/value pairs which provide additional
              metadata about the approval.
          createdAt:
            description: The date-time when the approval was created.
            type: string
            format: date-time
          updatedAt:
            description: The date-time when the approval was updated
            type: string
            format: date-time
          _embedded:
            description: The objects which participate in this association
            type: object
            properties:
              approvalType:
                description: The role for this association
                allOf:
                  - $ref: '#/definitions/summaryApprovalType'

    example:
      _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
      _profile: 'http://api.apiture.com/schemas/approvals/approvals/v0.1.0/profile.json'
      createdAt: '2019-04-17T10:04:46.375Z'
      updatedAt: '2019-04-17T10:12:58.375Z'
      _links:
        self:
          href: 'https://www.example.com/approvals/approvals/0399abed-fd3d-4830-a88b-30f38b8a365c'
        'apiture:approvalType':
          href: 'https://www.example.com/approvals/approvalTypes/e4f09b4d-eba6-46da-86d3-ba28595067cd'
        'apiture:target':
          href: 'https://www.example.com/vault/files/e4f09b4d-eba6-46da-86d3-hjr434fuhe'
        'apiture:approve':
          href: 'https://www.example.com/approvals/approvedApprovals?approval=0399abed-fd3d-4830-a88b-30f38b8a365c'
        'apiture:reject':
          href: 'https://www.example.com/approvals/rejectedApprovals?approval=0399abed-fd3d-4830-a88b-30f38b8a365c'
        'apiture:return':
          href: 'https://www.example.com/approvals/returnedApprovals?approval=0399abed-fd3d-4830-a88b-30f38b8a365c'
        'apiture:waive':
          href: 'https://www.example.com/approvals/waivedApprovals?approval=0399abed-fd3d-4830-a88b-30f38b8a365c'
      _embedded:
        approvalType:
          _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
          _profile: >-
            http://api.apiture.com/schemas/approvals/approvalTypes/v0.1.0/profile.json
          _links:
            self:
              href: 'https://www.example.com/approvals/approvalTypes/0399abed-fd3d-4830-a88b-30f38b8a365c'
          name: governmentId
          label: Government Issued ID
          description: A document that identifies a user

  summaryApprovalType:
    title: Approval Type Summary
    description: >-
      Summary representation of an approval type resource in approvals collections. This
      representation normally does not contain any `_embedded` objects. If
      needed, call the `GET` operation on the item's `self` link to get
      `_embedded` objects.
    x-apiture-reference: 'http://api.apiture.com/schemas/approvals/summaryApprovalType/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    allOf:
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          _id:
            description: >-
              The unique identifier for this approval resource. This is an
              immutable opaque string.
            type: string
          name:
            description: The approval's name.
            type: string
          label:
            description: The approval's common name.
            type: string
          description:
            description: The approval's description.
            type: string
          domain:
            description: >-
              A namespace for grouping related resources, to keep them
              separate from other resources. For example, a department or bank
              branch may define a domain, and all Approval Type instances they
              define will use that domain, so that they can avoid conflicting with
              Approval Type names in other domains. An API or service may define a
              domain for Approval Types that it defines. The combination of domain
              and name must be unique within the set of all resources of this
              type. It is a best practice to define domains with URIs. 
            type: string
    example:
      _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
      _profile: 'http://api.apiture.com/schemas/approvals/approvalTypes/v1.0.0/profile.json'
      _links:
        self:
          href: 'https://www.example.com/approvals/approvalTypes/0399abed-fd3d-4830-a88b-30f38b8a365c'

  verificationReport:
    title: Verification Report
    description: >-
      A verification report is an additional layer of validation that can be run against an instant verification resource.
      It uses available account aggregation data to generate a pass/fail result based on configured risk factors.
    allOf:
      - type: object
    properties:
      state:
        type: string
        description: >-
          The state of a verification report.  _passed_ indicates that the verification does not conain any risk factors
          based upon the user and account information, _failed_ indicates that the verification contains one or more risk factors.
        enum:
          - passed
          - failed
      accountRiskFactors:
        type: array
        items:
          $ref: '#/definitions/riskFactor'
    example:
      state: failed
      accountRiskFactors:
        - riskCode: 101
          description: Account owner first name does not match
        - riskCode: 102
          description: Account owner last name does not match
        - riskCode: 103
          description: Account owner zip code does not match

  riskFactor:
    title: Risk Factor
    description: A risk factor indicates a mismatch between user data and available account data.
    properties:
      riskCode:
        description: The risk factor risk code
        type: string
      description:
        description: The risk code description
        type: string
      attributes:
        $ref: '#/definitions/riskFactorAttributes'

  riskFactorAttributes:
    title: Risk Factor Attributes
    description: Details of the data used to determine a risk factor
    properties:
      value:
        description: Supplied value for risk factor analysis
        type: string
      expected:
        description: Known values referenced for risk factor analysis
        type: array
        items:
          type: string

  fraudRiskReport:
    title: Fraud-risk Report
    allOf:
      - $ref: '#/definitions/abstractResource'
      - $ref: '#/definitions/identityVerification'
      - properties:
          inputs:
            $ref: '#/definitions/fraudRiskReportInputs'
          outputs:
            $ref: '#/definitions/fraudRiskReportOutputs'
    example:
      _profile: 'https://api.apiture.com/schemas/identity/fraudRiskReport/v1.0.0/profile.json'
      _links:
        self:
          href: /identity/fraudRiskReports/c6dbc32f-e0eb-4947-9819-c691bb9164a5
        'apiture:contact':
          href: /contacts/contacts/6da5ccc7-727a-4256-bdd4-74023ae349c3
      _id: c6dbc32f-e0eb-4947-9819-c691bb9164a5
      type: fraudRiskReport
      inputs:
        identity:
          _profile: 'https://api.apiture.com/schemas/identity/identity/v1.0.0/profile.json'
          taxId: 555-55-5555
          firstName: John
          lastName: Smith
          address1: 1741 Tiburon Dr
          city: Wilmington
          region: NC
          postalCode: '28403'
          phone: 555-555-5555
          birthdate: '1940-10-15'
          email: api@apiture.com
          ipAddress: 127.0.0.1
      outputs:
        fraudRiskCategories:
          - type: personalInfoDoesNotMatch
            description: The retrieved identity does not match the provided PII.
          - type: addressIsHighRisk
            description: The provided address is considered high-risk
          - type: addressIsPOBoxOrNonApproved
            description: The provided address is a PO Box or other non-approved address
          - type: identityOnGovernmentWatchlist
            description: The provided identity is located on one or more watchlists
          - type: ipRestricted
            description: The provided IP address is restricted
          - type: emailRestricted
            description: The provided email address is restricted
          - type: nonStandardTaxId
            description: 'The provided taxId is non-standard. Example: The provided SSN is an ITIN (Individual Taxpayer  Identification Number)'
          - type: ageRestricted
            description: 'The provided identity does not meet the required age. Example: US COPPA laws forbid conducting e-commerce with people under 14 years of age.'
        token: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.XbPfbIHMI6arZ3Y922BhjWgQzWXcXNrz0ogtVhfEd2o

  fraudRiskCategory:
    title: Fraud-risk Category
    description: Representation of a fraud-risk category
    properties:
      type:
        $ref: '#/definitions/fraudRiskCategoryType'
      description:
        description: The description of the fraud.
        type: string
    example:
      type: addressIsPOBoxOrNonApproved
      description: The provided address is a PO Box or other non-approved address

  fraudRiskCategoryType:
    title: Fraud Risk Category Type
    description: Represents the possible types of fraud-risk
    type: string
    enum:
      - ipRestricted
      - identityOnGovernmentWatchlist
      - identityOnAlertList
      - addressIsPOBoxOrNonApproved
      - addressIsHighRisk
      - ageRestricted
      - nonStandardTaxId
      - personalInfoDoesNotMatch
      - emailRestricted

  fraudRiskReportOutputs:
    title: Fraud-risk Report Outputs
    description: The outputs of a fraud-risk report. Used for workflow
    allOf:
      - $ref: '#/definitions/outputs'
      - properties:
          fraudRiskCategories:
            type: array
            items:
              $ref: '#/definitions/fraudRiskCategory'

  fraudRiskReportInputs:
    title: Fraud-risk Report Inputs
    description: The inputs of a fraud-risk report. Used for workflow
    allOf:
      - $ref: '#/definitions/inputs'
      - properties:
          identity:
            $ref: '#/definitions/identity'

  inputs:
    title: Inputs
    description: Base model schema for identity verification operations inputs

  outputs:
    title: Outputs
    description: Base model schema for identity verification operations outputs
    allOf:
      - $ref: '#/definitions/verificationToken'

  verificationToken:
    title: Verification Token
    description: The token used to validate and track a contact for identity verification purposes.
    properties:
      token:
        type: string
        description: An opaque string that conveys the state of the contact's identity verification.

  identity:
    title: Identity
    description: Information that describes the identity
    required:
      - taxId
      - firstName
      - lastName
      - address1
      - city
      - region
      - postalCode
      - phone
      - birthdate
    properties:
      taxId:
        description: The identity's tax or government ID
        type: string
        maxLength: 128
        minLength: 1
      firstName:
        description: The identity's first name.
        type: string
        maxLength: 128
        minLength: 1
      lastName:
        description: The identity's last name.
        type: string
        maxLength: 128
        minLength: 1
      address1:
        description: Line 1 of the identity's street address.
        type: string
        maxLength: 512
        minLength: 1
      address2:
        description: Line 2 of the identity's street address.
        type: string
        maxLength: 512
        minLength: 1
      city:
        description: The identity's city.
        type: string
        maxLength: 64
        minLength: 1
      region:
        description: The identity's region.
        type: string
        maxLength: 128
        minLength: 1
      postalCode:
        description: The identity's postal code.
        type: string
        maxLength: 32
        minLength: 1
      phone:
        description: The identity's phone.
        type: string
        maxLength: 32
        minLength: 1
      birthdate:
        description: The identity's birth date in `yyyy-mm-dd` format.
        type: string
        format: date
        pattern: '^([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))$'
        maxLength: 10
        minLength: 10
      email:
        description: The identity's email address
        type: string
        format: email
        maxLength: 256
      ipAddress:
        description: The identity's IP address
        type: string
        format: ipv4
    example:
      taxId: 555-55-5555
      firstName: John
      lastName: Smith
      address1: 1741 Tiburon Dr
      city: Wilmington
      region: NC
      postalCode: '28403'
      phone: 555-555-5555
      birthdate: '1940-10-15'
      email: api@apiture.com
      ipAddress: 127.0.0.1

  identityVerification:
    title: Identity Verification Resource
    description: The core representation of an identity verification resource
    allOf:
      - $ref: '#/definitions/abstractResource'
      - $ref: '#/definitions/identityVerificationType'
      - properties:
          _id:
            type: string
            description: >-
              A unique identifier for this resource instance. This is is an opaque
              string.
          createdAt:
            description: The date-time when the resource was created.
            type: string
            format: date-time
          expiresAt:
            description: The date-time when the resource expires.
            type: string
            format: date-time

  identityVerificationType:
    title: Identity Verification Type
    description: Represents the possible types of identity verification
    properties:
      type:
        type: string
        enum:
          - fraudRiskReport
          - quiz
          - adminApproval

    example:
      _links:
        'apiture:contact':
          href: /contacts/contacts/6da5ccc7-727a-4256-bdd4-74023ae349c3
      verifications:
        - type: fraudRiskReport
          _links:
            self:
              href: /identity/fraudRiskReports/c6dbc32f-e0eb-4947-9819-c691bb9164a5
          state: passed
          verifiedAt: '2018-01-12T10:15:17Z'
        - type: quiz
          _links:
            self:
              href: /identity/quizzes/73be83af-9e64-4214-8e90-76da43610b31
          state: passed
          verifiedAt: '2018-01-12T10:19:41Z'

  businessVerifications: 
    title: Business Verifications
    description: >-
      Representation of the verification results that were previously generated by
      this service via the `POST /businessVerifications`. The result contains a link to
      `apiture:organization` if an `apiture:organization` link was passed on the request to create
      the report.
    allOf:
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          businessVerifications:
            description: An array of business verification resources
            type: array
            items:
              $ref: '#/definitions/businessVerification'
        example:
          businessVerifications: 
            - state: failed
              completedAt: '2018-04-17T10:04:46.375Z'
              type: 'verificationReport'
              _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
              _links:
                'apiture:verificationReport':
                  href: /businessVerifications/verificationReports/0399abed-fd3d-4830-a88b-30f38b8a365c
            - state: passed
              completedAt: '2018-04-17T10:04:46.375Z'
              type: 'administratorApproval'
              _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
              _links:
                'apiture:approval':
                  href: /approvals/approvals/0399abed-fd3d-4830-a88b-30f38b8a365c

  businessVerification: 
    title: Business Verification Report
    description: >-
      The verification report contains analsys of the business data and includes
      the state of the verification.
    properties:
      state:
        type: string
        description: The state of a verification report.  _passed_ indicates that the Business was successfully verified
          based upon the supplied information, _failed_ indicates it was not.
        enum:
          - passed
          - failed
      completedAt:
        description: An ISO 8601 UTC time stamp indicating when the verification report was created.
        type: string
        format: date-time
      type: 
        description: The identity method type. Possible values are `verificationReport` or `administratorApproval`.
        type: string
        enum:
          - verificationReport
          - administratorApproval
      _id:
        type: string
        description: This business verification's unique id
      _links: 
        $ref: '#/definitions/links'

  organization:
    title: Organization
    description: >-
      Representation of content and descriptive data (mailing addresses,
      phone numbers, email addresses) for an organization.
      An organization may have the following links in the `_links` object:
        * **`apiture:activate`** - Activate a new, pending organization
        * **`apiture:deactivate`** - Deactivate an organization (if it
        is active)
        * **`apiture:remove`** - Remove an inactive organization
    allOf:
      - $ref: '#/definitions/updateOrganization'
      - type: object
        properties:
          createdAt:
            description: The date-time when the organization was created.
            type: string
            format: date-time
          updatedAt:
            description: The date-time when the organization was updated
            type: string
            format: date-time
    example:
      _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
      _profile: 'http://api.apiture.com/schemas/organizations/organization/v0.1.0/profile.json'
      createdAt: '2018-04-17T10:04:46.375Z'
      updatedAt: '2018-04-17T10:12:58.375Z'
      _links:
        self:
          href: /organizations/organizations/0399abed-fd3d-4830-a88b-30f38b8a365c
        'apiture:deactivate':
          href: /organizations/inactiveOrganizations?organization=0399abed-fd3d-4830-a88b-30f38b8a365c
      _embedded: {}

  updateOrganization:
    title: Update Organization
    description: |-
      Representation used to update or patch an organization.
    allOf:
      - $ref: '#/definitions/summaryOrganization'
      - type: object
        properties:
          attributes:
            type: object
            description: >-
              An optional map of name/value pairs which provide additional
              metadata about the organization.
    example:
      _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
      _profile: 'http://api.apiture.com/schemas/organizations/organization/v1.0.0/profile.json'

  summaryOrganization:
    title: Organization Summary
    description: >-
      Summary representation of an organization resource in organizations collections. This
      representation normally does not contain any `_embedded` objects. If
      needed, call the `GET` operation on the item's `self` link to get
      `_embedded` objects.
    allOf:
      - $ref: '#/definitions/abstractResource'
      - $ref: '#/definitions/organizationFields'
      - type: object
        properties:
          _id:
            description: >-
              The unique identifier for this organization resource. This is an
              immutable opaque string.
            type: string
    example:
      _id: 0399abed-fd3d-4830-a88b-30f38b8a365c
      _profile: 'http://api.apiture.com/schemas/organizations/organization/v1.0.0/profile.json'
      _links:
        self:
          href: /organizations/organizations/0399abed-fd3d-4830-a88b-30f38b8a365c

  organizationFields:
    title: Organization Fields
    description: >-
      Common fields of the organization resource used to build other model schemas.
    properties:
      name:
        description: The organization's official full name
        type: string
      label:
        description: The organization's common name.
        type: string
      type:
        description: >-
          Indicates what type of organization this resource represents.
          <p>
          **NOTE**: This may move to a mutable `organizationTypes` configuration array
        type: string
        enum:
          - corporation
          - partnership
          - llc
          - llp
          - nonProfit
          - trust
          - municipality
      subtype:
        description: >-
          A refinement of the `type`.
          <p>
          **NOTE**: This may move to a mutable `organizationSubTypes` configuration array</p>
        type: string
        enum:
          - soleProprietorship
          - partnership
          - limitedPartnership
          - corporation
          - sCorporation
          - limitedLiabilityCompany
          - revokableTrust
          - irrevocableTrust
          - assetProtectionTrust
          - charitableTrust
          - constructiveTrust
          - specialNeedsTrust
          - spendthriftTrust
          - taxBypassTrust
          - tottenTrust
          - other         
      identification:
        description: >-
          A collection of official identifying information associated with the contact.
          This currently only supports government tax ID.
        type: array
        items:
          type: object
          required:
            - type
            - value
          properties:
            value:
              description: >-
                The value of this form of identification (the tax ID as a string, for example)
              type: string
            type:
              description: >-
                The type of this form of identification. `taxId` is the
                only supported type at this time.
              type: string
              enum:
                - taxId
                - dunsNumber
            expiration:
              description: >-
                The date when the form of identification expires.
              type: string
              format: date
      addresses:
        description: An array of postal mailing addresses for this organization.
        type: array
        items: 
          type: object
          $ref: '#/definitions/address'
      phones:
        description: A collection of phone numbers associated with the organization.
        type: array
        items:
          type: object
          properties:
            type:
              description: >-
                The type of phone number this represents.
              type: string
              enum:
                - home
                - work
                - mobile
                - other
            number:
              description: >-
                The phone number, as a string.
              type: string
              example: 555-555-5555
      emailAddresses:
        description: >-
          An array of email addresses associated with the organization.
          The first item, if present, is the default (preferred)
          organization email.
        type: array
        items: 
          type: string
          format: email
      finxactId:
        type: string
      state:
        description: The state of this organization.
        type: string
        enum:
          - pending
          - inactive
          - active
          - merged
          - removed
      tradeName:
        type: string
        description: The trade name of the organization.
      establishedDate:
        description: The date the organization was established.
        type: string
        format: date
      governmentOwned:
        description: Indicates whether the organization is a government-owned entity.
        type: boolean
      publiclyHeld:
        description: Indicates whether the organization is publicly held.
        type: boolean
      smallBusiness:
        description: Indicates whether the organization is classified as a small business
        type: boolean
      taxExempt:
        description: Indicates whether the organization is the tax-exempt.
        type: boolean
      employeeCountLowerBound:
        description: The lower bound of persons employed.
        type: number
        minimum: 1
      employeeCountUpperBound:
        description: The upper bound of persons employed.
        type: number
        maximum: 20000000
      homeUrl:
        description: The organization's home page.
        type: string
      industry:
        description: Indicates what industry does this organization work within.
        type: string
      countryOfOperations:
        type: string
        description: The ISO 3166-1 country code for the organization's operation.
        minLength: 2
        maxLength: 2
      regulatory:
        description: An object containing answers to organization specific regulatory questions.
        type: object
      currency:
        description: >-
          The [ISO 4217 currency code](https://en.wikipedia.org/wiki/ISO_4217) for this monetary value. This is always upper case ASCII. TODO: ISO 4217 defines three-character codes. However, ISO 4217 does not account
          for cryptocurrencies. Of note, DASH uses 4 characters.
        type: string
        minLength: 3
        maxLength: 3
      estimatedAnnualRevenue:
        description: Dollar amount of estimated revenue.
        type: string
      mobileCheckDepositEnabled:
        description: Indicates that the organization use mobile check deposits.
        type: boolean
      achEnabled:
        description: Indicates that the organization use ACH transfers.
        type: boolean
      estimatedMonthlyAmounts:
        type: object
        description: Indicates the estimated monthly amounts for wires, mobile deposits and ACH
        properties:
          sentWire:
            description: Indicates the estimated monthly minimum wires amount sent.
            type: string
          receivedWire:
            description: Indicates the estimated monthly minimum wires amount received.
            type: string
          mobileCheckDeposit:
            description: Indicates the estimated monthly minimum amount to deposit.
            type: string
          receivedAch:
            description: Indicates the estimated monthly total amount to receive by ACH.
            type: string
          sentAch:
            description: Indicates the estimated monthly total amount to send by ACH.
            type: string
    example:
      name: "Smith's Auto Detailing"
      label: "Smith's Detailing"
      emailAddresses:
        - smitties-detailing@example.com
      phones:
        - type: work
          number: "(555) 555-5555"
        - type: mobile
          number: "(999) 555-5555"
      addresses:
        - type: work
          addressLine1: 555 N Front Street
          addressLine2: Suite 5555
          city: Wilmington
          regionCode: NC
          postalCode: 28401-5405
          countryCode: US
        - type: work
          addressLine1: 123 S 3rd Street
          addressLine2: Apt 42
          city: Wilmington
          regionCode: NC
          postalCode: 28411-5405
          countryCode: US
          state: active
          currency: 'USD'
          estimatedAnnualRevenue: '125000.51'
          estimatedMonthlyAmounts:
            sentWire: '20000.00'
            receivedWire: '30000.00'
            mobileCheckDeposit: '250000.00'
            receivedAch: '40000.00'
            sentAch: '35000.00'

  configuration:
    title: Configuration
    description: >-
      Represents the configuration for the Applications API
    properties:
      _links:
        $ref: '#/definitions/links'
    example:
      _links:
        self:
          href: /accountApplications/configuration/
        'apiture:groups':
          href: /accountApplications/configuration/groups

  configurationGroups:
    title: Configuration Group Collection
    description: >-
      Collection of configuration groups. The items in the collection are ordered in the
      `_embedded` object with name `items`. The top-level `_links` object may
      contain pagination links (`self`, `next`, `prev`, `first`, `last`,
      `collection`.)
    allOf:
      - $ref: '#/definitions/collection'
      - type: object
        properties:
          _embedded:
            type: object
            properties:
              items:
                description: An array containing a page of configuration group items.
                type: array
                items:
                  $ref: '#/definitions/configurationGroupSummary'
    example:
      _profile: 'http://api.apiture.com/schemas/accountApplications/configurationGroups/v1.0.0/profile.json'
      start: 10
      limit: 10
      count: 67
      name: configurationGroups
      _links:
        self:
          href: /accountApplications/configuration/groups?start=10&limit=10
        first:
          href: /accountApplications/configuration/groups?start=0&limit=10
        next:
          href: /accountApplications/configuration/groups?start=20&limit=10
        collection:
          href: /accountApplications/configuration/groups
      _embedded:
        items:
          - _profile: 'http://api.apiture.com/schemas/accountApplications/configurationGroup/v1.0.0/profile.json'
            _links:
              self:
                href: /configuration/groups/basic
              'apiture:configuration':
                href: /configuration
            name: basic
            label: Basic Settings
            description: The basic settings for the Applications API

  configurationGroupSummary:
    title: Configuration Group Summary
    description: >-
      A summary of the data contained within a configuration group resource
    allOf:
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          name:
            description: >-
              The name of this configuration group, must be unique within the set of all resources of this type.
            type: string
            maxLength: 48
            minLength: 1
            pattern: '[a-zA-Z][-\w_]*'
            example: applications
          label:
            description: >-
              The text label for this resource, suitable for presentation to
              the client.
            type: string
            maxLength: 128
            minLength: 1
            example: 'Applications Configuration'
          description:
            description: >-
              The full description for this resource, suitable for presentation to
              the client.
            type: string
            maxLength: 4096
            minLength: 1
            example: >-
              The configuration for the Applications API.

  configurationGroup:
    title: Configuration Group
    description: >-
      Represents a configuration group.
    allOf:
      - $ref: '#/definitions/configurationGroupSummary'
      - type: object
        properties:
          schema:
            $ref: '#/definitions/configurationSchema'
          values:
            $ref: '#/definitions/configurationValues'
    example:
      _profile: 'http://api.apiture.com/schemas/accountApplications/configurationGroup/v1.0.0/profile.json'
      _links:
        self:
          href: /configuration/groups/basic
        'apiture:configuration':
          href: /configuration
      name: basic
      label: Basic Settings
      description: The basic settings for the Applications API
      schema:
        type: object
        properties:
          defaultPersonalWorkflowDefinitionUri:
            type: string
            description: The default workflow definition uri to use for personal product types
          defaultBusinessWorkflowDefinitionUri:
            type: string
            description: The default workflow definition uri to use for business product types
      values:
        defaultPersonalWorkflowDefinitionUri: 'http://api.apiture.com/workflow/workflowDefinitions/5311b7f6-8370-4b24-9050-9b030f432eb2'
        defaultBusinessWorkflowDefinitionUri: 'http://api.apiture.com/workflow/workflowDefinitions/260d3dec-214e-4010-8448-898c4c07f1ae'

  configurationSchema:
    title: Configuration Schema
    description: >-
      The schema which defines the name and types of the
      variables that are part of this configuration definition.
      Property names must be simple identifiers
      consisting of alphanumeric characters, `-`, `_`
      following the pattern _`letter [letter | digit | '-' | '_']*`_

      This is implicitly a schema for `type: object`
      and contains the properties.


      The `values` in a configuration conform to the schema.
      The names and types are described with a subset of
      [JSON Schema Core](https://tools.ietf.org/html/draft-zyp-json-schema-04)
      and [JSON Schema Validation](https://tools.ietf.org/html/draft-fge-json-schema-validation-00)
      similar to that used to define schemas in
      [OpenAPI Specification 2.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md#schemaObject).
    example:
      type: object
      properties:
        defaultPersonalWorkflowDefinitionUri:
          type: string
          description: The default workflow definition uri to use for personal product types
        defaultBusinessWorkflowDefinitionUri:
          type: string
          description: The default workflow definition uri to use for business product types

  configurationValues:
    title: Configuration Values
    description: >-
      The data associated with this configuration: the resource's
      variable names and values. These values must conform to this
      item's `schema`.               
        
      *Note*: the `schema` may also contain `default` values
      which, if present, are used if a value is *not* set in the
      definition's `values`.
      (For example, multiple configurations may use the same schema
      that defines values `a`, `b`, and `c`, but each configuration
      may have their own unique values for `a`, `b`, and `c`
      which is separate from the schema.)
    example:
      defaultPersonalWorkflowDefinitionUri: 'http://api.apiture.com/workflow/workflowDefinitions/5311b7f6-8370-4b24-9050-9b030f432eb2'
      defaultBusinessWorkflowDefinitionUri: 'http://api.apiture.com/workflow/workflowDefinitions/260d3dec-214e-4010-8448-898c4c07f1ae'

  abstractResource:
    x-apiture-version: 1.0.0
    title: Abstract Resource
    description: >-
      An augmented [HAL](https://tools.ietf.org/html/draft-kelly-json-hal-08)
      resource representation. This model contains hypermedia `_links`, and
      either optional domain object data with `_profile` and optional
      `_embedded` objects, or an `_error` object. In responses, if the operation
      was successful, this object will not include the `_error`, but if the
      operation was a 4xx or 5xx error, this object will not include `_embedded`
      or any data fields, only `_error` and optionally `_links`.
    x-apiture-reference: 'http://api.apiture.com/schemas/common/abstractResource/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    example:
      _profile: 'http://api.apiture.com/schemas/example/v1.0.0/profile.json'
      _links:
        self:
          href: '{uri of current resource}'
    properties:
      _links:
        description: >-
          An optional map of links, mapping each link relation to a link object.
          This model defines the `_links` object of HAL representations.
        type: object
        additionalProperties:
          $ref: '#/definitions/link'
        $ref: '#/definitions/links'
      _embedded:
        description: >-
          An optional map of nested resources, mapping each nested resource name
          to a nested resource representation.
        type: object
      _profile:
        description: >-
          The URI of a [resource
          profile](https://developer.apiture.com/docs/concepts/profiles) which
          describes the representation.
        type: string
        format: uri
      _error:
        description: >-
          An object which describes an error. This value is omitted if the
          operation succeeded without error.
        type: object
        allOf:
          - $ref: '#/definitions/error'

  root:
    x-apiture-version: 1.0.0
    title: API Root
    description: >-
      A HAL response, with hypermedia `_links` for the top-level resources and
      operations in API.
    x-apiture-reference: 'http://api.apiture.com/common/root/bbb/v1.0.0/schema.json'
    example:
      id: apiName
      name: API name
      apiVersion: 0.0.1-SNAPSHOT
      _profile: 'https://api.apiture.com/schemas/root/v1.0.0/profile.json'
      _links: {}
    allOf:
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          _id:
            type: string
            description: This API's unique ID.
          name:
            type: string
            description: This API's name.
          apiVersion:
            type: string
            description: This API's version.

  errorResponse:
    x-apiture-version: 1.0.0
    title: Error Response
    description: >-
      Describes an error response, typically returned on 4xx or 5xx errors from
      API operations. The `_error` object contains the error details.
    x-apiture-reference: 'http://api.apiture.com/schemas/common/errorResponse/v1.0.0/schema.json'
    allOf:
      - $ref: '#/definitions/abstractResource'
    example:
      _profile: 'http://api.apiture.com/schemas/error/v1.0.0/profile.json'
      _error:
        _id: 2eae46e1-575c-4d69-8a8f-0a7b0115a4b3
        _profile: 'https://api.apiture.com/schemas/error/v1.0.0/profile.json'
        message: The value for deposit must be greater than 0.
        statusCode: 422
        type: positiveNumberRequired
        attributes:
          value: -125.5
        remediation: Provide a value which is greater than 0
        occurredAt: 2018-01-25T05:50:52.375Z
        _links:
          describedby:
            href: 'https://developer.apiture.com/errors/positiveNumberRequired'
        _embedded:
          errors: []

  error:
    x-apiture-version: 1.0.0
    title: Error
    description: >-
      An error description. Nested source errors are contained in the
      `_embedded` object with the key `"errors"`; this is an array of nested
      error objects. For example, an API which validates its request body may
      find multiple errors in the request, which may be detailed here. The
      `_links` may contain a `describedby` link which refers to a web page with
      details about the error.
      The `attributes` field An optional map of name/value pairs which provide
      structured data about the error. For example, if the error is a value out
      of range, the attributes may specify the range values `min` and `max`.
      This allows clients to present error messages as they see fit (the API
      does not assume the client/presentation tier).
    x-apiture-reference: 'http://api.apiture.com/schemas/common/error/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    required:
      - message
    properties:
      message:
        type: string
        description: A localized message string describing the error condition.
      _id:
        type: string
        description: >-
          A unique identifier for this error instance. This may be used as a
          correlation ID with the root cause error (i.e. this ID may be logged
          at the source of the error). This is is an opaque string.
      statusCode:
        description: The HTTP status code associate with this error.
        type: integer
        minimum: 100
        maximum: 599
        example: 422
      type:
        type: string
        description: >-
          An error identifier which indicates the category of error and
          associate it with API support documentation or which the UI tier can
          use to render an appropriate message or hint. This provides a finer
          level of granularity than the `statusCode`. For example, instead of
          just 400 Bad Request, the `type` may be much more specific. such as
          `integerValueNotInAllowedRange` or `numericValueExceedsMaximum` or
          `stringValueNotInAllowedSet`.
      occurredAt:
        type: string
        format: date-time
        description: >-
          An [RFC 3339](https://tools.ietf.org/html/rfc3339)
          UTC time stamp (`YYYY-MM-DDThh:mm:ss.sssZ` format) indicating when the error occurred.
        example: '2019-02-02T03:37:15.375Z'
      attributes:
        description: >-
          Data attribute associated with the error, such as values or
          constraints.
        allOf:
          - $ref: '#/definitions/attributes'
      remediation:
        type: string
        description: >-
          An optional localized string which provides hints for how the user or
          client can resolve the error.
      _embedded:
        description: >-
          Optional embedded array of errors. This field may not exist if the
          error does not have nested errors.
        type: object
        properties:
          items:
            description: An array of error objects.
            type: array
            items:
              $ref: '#/definitions/errorResponse'
    example:
      _id: 2eae46e1-575c-4d69-8a8f-0a7b0115a4b3
      _profile: 'https://api.apiture.com/schemas/error/v1.0.0/profile.json'
      message: The value for deposit must be greater than 0.
      statusCode: 422
      type: positiveNumberRequired
      attributes:
        value: -125.5
      remediation: Provide a value which is greater than 0
      occurredAt: '2019-01-25T05:50:52.375Z'
      _links:
        describedby:
          href: 'https://developer.apiture.com/errors/positiveNumberRequired'
      _embedded:
        errors: []

  attributes:
    x-apiture-version: 1.0.0
    title: Attributes
    description: >-
      An optional map of name/value pairs which contains additional dynamic data
      about the resource.
    type: object
    x-apiture-reference: 'http://api.apiture.com/schemas/common/attributes/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true

  link:
    x-apiture-version: 1.0.0
    title: Link
    description: >-
      Describes a hypermedia link within a `_links` object in HAL
      representations. In Apiture APIs, links are [HAL
      links](https://tools.ietf.org/html/draft-kelly-json-hal-08#section-5), but
      Apiture APIs do not use the `name` or `hreflang` properties of HAL.
      Apiture links _may_ include a `method` property.
    x-apiture-reference: 'http://api.apiture.com/schemas/common/link/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    required:
      - href
    properties:
      href:
        type: string
        format: uri
        description: >-
          The URI or URI template for the resource/operation this link refers
          to.
      type:
        type: string
        description: The media type for the resource.
      templated:
        type: boolean
        description: >-
          If true, the link's href is a [URI
          template](https://tools.ietf.org/html/rfc6570).
      title:
        type: string
        description: An optional human-readable localized title for the link.
      deprecation:
        type: string
        format: uri
        description: >-
          If present, the containing link is deprecated and the value is a URI
          which provides human-readable text information about the deprecation.
      profile:
        type: string
        format: uri
        description: >-
          The URI of a profile document, a JSON document which describes the
          target resource/operation.

  collection:
    x-apiture-version: 1.0.0
    title: Collection
    description: >-
      A collection of resources. This is an abstract model schema which is
      extended to define specific resource collections.
    x-apiture-reference: 'http://api.apiture.com/schemas/common/collection/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    allOf:
      - $ref: '#/definitions/abstractResource'
      - type: object
        properties:
          count:
            description: The number of items in the full collection.
            type: integer
          start:
            description: The start index of this page of items.
            type: integer
          limit:
            description: The maximum number of items per page.
            type: integer
          name:
            description: The name of the collection.
            type: string

  links:
    title: Links
    description: >-
      An optional map of links, mapping each link relation to a link object.
      This model defines the `_links` object of HAL representations.
    x-apiture-reference: 'http://api.apiture.com/schemas/common/links/v1.0.0/schema.json'
    x-apiture-traits:
      fragment: true
    type: object
    additionalProperties:
      $ref: '#/definitions/link'

x-apiture-traits:
  - api:
      title: Account Applications
      basePath: accountApplications
      links:
        - getApplications
        - createApplication
        - getApi
        - getApiDoc

  - resource:
      name: account application
      resource: application
      collection: applications
  - state:
      name: application
      state: running
      verb: start
  - state:
      name: application
      state: canceled
      verb: cancel
  - state:
      name: application
      state: approved
      verb: approve
  - state:
      name: application
      state: rejected
      verb: reject
  - state:
      name: application
      state: expired
      verb: expire

x-apiture-errors:
  accessForbidden:
    description: The credentials supplied in the request are insufficient to grant access
    remediation: Check the supplied credentials for validity

  applicationNotFound:
    description: No applications were found for the specified applicationId
    remediation: Check to make sure that the supplied applicationId corresponds to an apiture application resource

  invalidContactId:
    description: No contact was found for the specified contactId
    remediation: Check to make sure that the supplied contactId corresponds to an apiture contact resource

  preconditionFailed:
    description: The supplied `if-Match` header value does not match the most recent `ETag` response header value. The resource has changed in the interim
    remediation: Resubmit the operation, supplying the value of the ETag and the most recent state of the resource
  
  preconditionRequired:
    description: Precondition Required. The request did not include the required if-Match header
    remediation: Resubmit with the operation, supplying the value of the ETag and the most recent state of the resource

  productNotFound:
    description: No Products were found for the specified productId
    remediation: Check to make sure that the supplied productId corresponds to an apiture product resource
  
  productNotSupplied:
    description: A link to the product was not supplied for the account
    remediation: Include a link to a valid apiture product in the _links object of your request

  internalError:
    description: An unexpected interal server error occurred.
    remediation: Retry the operation again

  emptyRequestBody:
    description: The supplied request body was empty
    remediation: Check to make sure the body is included in your request

  malformedApplicationUri:
    description: The supplied applicationUri was malformed
    remediation: Check to make sure that the supplied applicationUri corresponds to an apiture application resource

  invalidGroupName:
    description: No configurationGroup was found for the specified groupName
    remediation: Check to make sure that the supplied groupName corresponds to an apiture transfer configuration group resource

  invalidValueName:
    description: No configurationName was found for the specified valueName
    remediation: Check to make sure that the supplied valueName corresponds to an apiture transfer configuration value resource

  invalidConfigurationGroup:
    description: The request body did not conform to the schema for this configuration group
    remediation: Check the schema for the configuration group and resubmit the operation

  invalidConfigurationValue:
    description: The request body did not conform to the schema for this configuration group value
    remediation: Check the schema for the configuration group value and resubmit the operation
