# Create Authentication

# Overview
Use this API to register client callback Authentication methods using oAuth or Basic Authentication. This is the first step in creating a new Conversation Account.
New Account API process flow: **Authenticiation** > Client Application > Participant > Channel > Orchestration > Account
Use the ID returned in the response when creating the client application.
The Conversation Manager also uses this authentication method when sending messages to the callback URL of the client application.
## Scope
Client application must have 'app.conversation.conversationmgr.manage' scope assigned.

Endpoint: POST /authentications
Security: oAuthClient

## Description:

  - `Overview` ()
    Use this API to register client callback Authentication methods using oAuth or Basic Authentication. This is the first step in creating a new Conversation Account.New Account API process flow: Authenticiation > Client Application > Participant > Channel > Orchestration > AccountUse the ID returned in the response when creating the client application.The Conversation Manager also uses this authentication method when sending messages to the callback URL of the client application.

  - `Scope` ()
    Client application must have 'app.conversation.conversationmgr.manage' scope assigned.

## Security:

  - `oAuthClient` (unknown)
    oauth2 scopes: https://api.egain.cloud/auth/.default

## Request body:

  - `application/json` (unknown)
    Register new authentication type

## Request fields (application/json):

  - `name` (string, required)
    Unique name for authentication method

  - `description` (string)

  - `active` (boolean)

  - `type` (string, required)
    Type of authentication
    Enum: "oauth2"

  - `oauth2` (object, required)

  - `oauth2.tokenRequestUrl` (string, required)
    Access token API

  - `oauth2.method` (string, required)
    Http method for access token API
    Enum: "POST", "GET"

  - `oauth2.headers` (array, required)

  - `oauth2.headers.name` (string, required)
    name of attribute

  - `oauth2.headers.value` (string, required)
    value of attribute

  - `oauth2.payload` (string, required)
    Access token request payload

  - `oauth2.accessTokenPath` (string, required)
    The JSON query path of an access token in the returned JSON response
    Example: $.accessToken

  - `type` (string, required)
    Type of authentication
    Enum: "basic"

  - `basicAuth` (object, required)

  - `basicAuth.username` (string, required)

  - `basicAuth.password` (string, required)

## Request examples:

  - `OAuth` (unknown)
    OAuth type authentication

  - `Basic Auth` (unknown)
    OAuth type authentication

## Response 201:

  - `201` (unknown)
    Created

## Response 201 fields (application/json):

  - `id` (string)
    UUID generated for the object.

## Response 400:

  - `400` (unknown)
    Bad Request

## Response 400 fields (application/json):

  - `code` (string, required)
    String that follow the pattern {integer}-{integer}.
* The first part is http status code.  The code is unique as a whole. Nothing common between 400-101 and 404-101

  - `developerMessage` (string, required)
    Response explaining what happened

  - `details` (array)

  - `details.key` (string, required)

  - `details.value` (string)

  - `userMessage` (string)
    UI friendly message only supported by some API.
* Client must request explicitly by passing X-egain-error-message=yes header

## Response 401:

  - `401` (unknown)
    Unauthorized

## Response 401 fields (application/json):

  - `code` (string, required)
    String that follow the pattern {integer}-{integer}.
* The first part is http status code.  The code is unique as a whole. Nothing common between 400-101 and 404-101

  - `developerMessage` (string, required)
    Response explaining what happened

  - `details` (array)

  - `details.key` (string, required)

  - `details.value` (string)

  - `userMessage` (string)
    UI friendly message only supported by some API.
* Client must request explicitly by passing X-egain-error-message=yes header

## Response 403:

  - `403` (unknown)
    Forbidden

## Response 403 fields (application/json):

  - `code` (string, required)
    String that follow the pattern {integer}-{integer}.
* The first part is http status code.  The code is unique as a whole. Nothing common between 400-101 and 404-101

  - `developerMessage` (string, required)
    Response explaining what happened

  - `details` (array)

  - `details.key` (string, required)

  - `details.value` (string)

  - `userMessage` (string)
    UI friendly message only supported by some API.
* Client must request explicitly by passing X-egain-error-message=yes header

## Response 500:

  - `500` (unknown)
    Internal server error

## Response 500 fields (application/json):

  - `code` (string, required)
    String that follow the pattern {integer}-{integer}.
* The first part is http status code.  The code is unique as a whole. Nothing common between 400-101 and 404-101

  - `developerMessage` (string, required)
    Response explaining what happened

  - `details` (array)

  - `details.key` (string, required)

  - `details.value` (string)

  - `userMessage` (string)
    UI friendly message only supported by some API.
* Client must request explicitly by passing X-egain-error-message=yes header

## Response 400 examples:

  - `Required Attribute missing` (unknown)
    Required attribute is missing in payload

  - `Duplicate Resource Found` (unknown)
    Resouce with same details found

  - `Unallowed attribute value` (unknown)
    One of the attribute has value which is not allowed

  - `Max length exceeded` (unknown)
    Attribute value has length that exceeds limit

  - `Unknown Attribute Present` (unknown)
    Unknown attribute present in request body

  - `Value doesn't match pattern` (unknown)
    Attribute value doesn't match pattern of allowed characters

## Response 401 examples:

  - `Invalid Authorization` (unknown)
    Invalid on expired Authorization. Generate new Authorization header and try again.

## Response 403 examples:

  - `Required Scope Missing` (unknown)
    OAuth Client application used for generating Authorization token doesn't have required scope to call this API.
Refer API description to know which scope needs to be assigned to OAuth client.

## Response 500 examples:

  - `Internal Server Error` (unknown)

