> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://apidoc-v1.maniscloud.com/llms.txt.
> For full documentation content, see https://apidoc-v1.maniscloud.com/llms-full.txt.

# Get token

POST https://api/v1/auth/token

This API endpoint allows clients to retrieve an access token by providing valid authentication credentials. The access token is used to authorize subsequent API requests.

**Request Header**

- `x-secret:` the merchant's secret
    
- `x-merchant-id:`the merchant's id
    

**Response Body**

200 OK

| **Field** | type |
| --- | --- |
| tokenType | string |
| token | string |
| expiresAt | timestamp |

400 BAD REQUEST

| **Field** | type |
| --- | --- |
| timestamp | date(yyyy-MM-dd'T'HH:mm:ss.SSS'Z') |
| title | string |
| type | string |
| status | number |
| soaCode | string |
| detail | string |

Reference: https://apidoc-v1.maniscloud.com/manis-unified-api-v-1-0/authentication/get-token

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: collection
  version: 1.0.0
paths:
  /api/v1/auth/token:
    post:
      operationId: get-token
      summary: Get token
      description: >-
        This API endpoint allows clients to retrieve an access token by
        providing valid authentication credentials. The access token is used to
        authorize subsequent API requests.


        **Request Header**


        - `x-secret:` the merchant's secret
            
        - `x-merchant-id:`the merchant's id
            

        **Response Body**


        200 OK


        | **Field** | type |

        | --- | --- |

        | tokenType | string |

        | token | string |

        | expiresAt | timestamp |


        400 BAD REQUEST


        | **Field** | type |

        | --- | --- |

        | timestamp | date(yyyy-MM-dd'T'HH:mm:ss.SSS'Z') |

        | title | string |

        | type | string |

        | status | number |

        | soaCode | string |

        | detail | string |
      tags:
        - subpackage_authentication
      parameters:
        - name: x-merchant-id
          in: header
          required: false
          schema:
            type: string
        - name: x-secret
          in: header
          required: false
          schema:
            type: string
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Authentication_Get token_Response_200'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PostApiV1AuthTokenRequestBadRequestError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/PostApiV1AuthTokenRequestUnauthorizedError
servers:
  - url: https:/
components:
  schemas:
    Authentication_Get token_Response_200:
      type: object
      properties:
        token:
          type: string
        expiresAt:
          type: integer
        tokenType:
          type: string
      required:
        - token
        - expiresAt
        - tokenType
      title: Authentication_Get token_Response_200
    PostApiV1AuthTokenRequestBadRequestError:
      type: object
      properties:
        message:
          type: string
        timestamp:
          type: string
          format: date
      required:
        - message
        - timestamp
      title: PostApiV1AuthTokenRequestBadRequestError
    PostApiV1AuthTokenRequestUnauthorizedError:
      type: object
      properties:
        message:
          type: string
        timestamp:
          type: string
          format: date
      required:
        - message
        - timestamp
      title: PostApiV1AuthTokenRequestUnauthorizedError

```

## SDK Code Examples

```python Authentication_Get token_example
import requests

url = "https://https/api/v1/auth/token"

headers = {
    "x-merchant-id": "{{merchantId}}",
    "x-secret": "{{merchantSecret}}"
}

response = requests.post(url, headers=headers)

print(response.json())
```

```javascript Authentication_Get token_example
const url = 'https://https/api/v1/auth/token';
const options = {
  method: 'POST',
  headers: {'x-merchant-id': '{{merchantId}}', 'x-secret': '{{merchantSecret}}'}
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Authentication_Get token_example
package main

import (
	"fmt"
	"net/http"
	"io"
)

func main() {

	url := "https://https/api/v1/auth/token"

	req, _ := http.NewRequest("POST", url, nil)

	req.Header.Add("x-merchant-id", "{{merchantId}}")
	req.Header.Add("x-secret", "{{merchantSecret}}")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Authentication_Get token_example
require 'uri'
require 'net/http'

url = URI("https://https/api/v1/auth/token")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["x-merchant-id"] = '{{merchantId}}'
request["x-secret"] = '{{merchantSecret}}'

response = http.request(request)
puts response.read_body
```

```java Authentication_Get token_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://https/api/v1/auth/token")
  .header("x-merchant-id", "{{merchantId}}")
  .header("x-secret", "{{merchantSecret}}")
  .asString();
```

```php Authentication_Get token_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://https/api/v1/auth/token', [
  'headers' => [
    'x-merchant-id' => '{{merchantId}}',
    'x-secret' => '{{merchantSecret}}',
  ],
]);

echo $response->getBody();
```

```csharp Authentication_Get token_example
using RestSharp;

var client = new RestClient("https://https/api/v1/auth/token");
var request = new RestRequest(Method.POST);
request.AddHeader("x-merchant-id", "{{merchantId}}");
request.AddHeader("x-secret", "{{merchantSecret}}");
IRestResponse response = client.Execute(request);
```

```swift Authentication_Get token_example
import Foundation

let headers = [
  "x-merchant-id": "{{merchantId}}",
  "x-secret": "{{merchantSecret}}"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://https/api/v1/auth/token")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```