> This page is for Talent.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://paylocity-develop.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://paylocity-develop.ferndocs.com/_mcp/server.

# Get Bearer Token

POST https://api.paylocity.com/public/security/v1/token
Content-Type: application/x-www-form-urlencoded

Obtain an OAuth 2.0 access token using the **client credentials** grant. Send `client_id`, `client_secret`, and `grant_type=client_credentials` as `application/x-www-form-urlencoded` data. See [Authentication](https://developer.paylocity.com/integrations/reference/authentication).

Reference: https://paylocity-develop.ferndocs.com/talent/api-reference/paylocity-ap-is/authentication/get-access-token

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Request

### Body (application/x-www-form-urlencoded)

This endpoint expects an object.

- `grant_type` (enum, required) — Must be `client_credentials` for this flow.
  - Allowed values: `client_credentials`
- `client_id` (string, required) — Connected App client ID from the Developer Portal.
- `client_secret` (string, required) — Connected App client secret from the Developer Portal.

## Response

### 200

Successful response

- `access_token` (string, required) — Bearer token value sent as `Authorization: Bearer <access_token>`.
- `token_type` (enum, required) — Token type; `Bearer` for this flow.
  - Allowed values: `Bearer`
- `expires_in` (integer, required) — Lifetime of the access token in seconds (typically 3600).

## Errors

### 401 Unauthorized Error

Authentication failed, or the `Authorization` bearer token is missing, invalid, or expired. Obtain a new token from `/public/security/v1/token` using the client-credentials flow (see [Authentication](https://developer.paylocity.com/integrations/reference/authentication)).

- `any`

## Examples

### Sample token response (from Paylocity authentication documentation)

**Response**

```json
{
  "access_token": "....",
  "token_type": "Bearer",
  "expires_in": 3600
}
```

**SDK Code**

```python Sample token response (from Paylocity authentication documentation)
import requests

url = "https://api.paylocity.com/public/security/v1/token"

headers = {"Authorization": "Bearer <token>"}

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

print(response.json())
```

```javascript Sample token response (from Paylocity authentication documentation)
const url = 'https://api.paylocity.com/public/security/v1/token';
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};

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

```go Sample token response (from Paylocity authentication documentation)
package main

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

func main() {

	url := "https://api.paylocity.com/public/security/v1/token"

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

	req.Header.Add("Authorization", "Bearer <token>")

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

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

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

}
```

```ruby Sample token response (from Paylocity authentication documentation)
require 'uri'
require 'net/http'

url = URI("https://api.paylocity.com/public/security/v1/token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'

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

```java Sample token response (from Paylocity authentication documentation)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.paylocity.com/public/security/v1/token")
  .header("Authorization", "Bearer <token>")
  .asString();
```

```php Sample token response (from Paylocity authentication documentation)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.paylocity.com/public/security/v1/token', [
  'headers' => [
    'Authorization' => 'Bearer <token>',
  ],
]);

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

```csharp Sample token response (from Paylocity authentication documentation)
using RestSharp;

var client = new RestClient("https://api.paylocity.com/public/security/v1/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift Sample token response (from Paylocity authentication documentation)
import Foundation

let headers = ["Authorization": "Bearer <token>"]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.paylocity.com/public/security/v1/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()
```

### Client credentials (form fields)

**Request**

```json
{
  "grant_type": "client_credentials",
  "client_id": "<your client id>",
  "client_secret": "<your secret>"
}
```

**Response**

```json
{
  "access_token": "....",
  "token_type": "Bearer",
  "expires_in": 3600
}
```

**SDK Code**

```python Client credentials (form fields)
import requests

url = "https://api.paylocity.com/public/security/v1/token"

payload = ""
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/x-www-form-urlencoded"
}

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

print(response.json())
```

```javascript Client credentials (form fields)
const url = 'https://api.paylocity.com/public/security/v1/token';
const options = {
  method: 'POST',
  headers: {
    Authorization: 'Bearer <token>',
    'Content-Type': 'application/x-www-form-urlencoded'
  },
  body: new URLSearchParams('')
};

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

```go Client credentials (form fields)
package main

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

func main() {

	url := "https://api.paylocity.com/public/security/v1/token"

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

	req.Header.Add("Authorization", "Bearer <token>")
	req.Header.Add("Content-Type", "application/x-www-form-urlencoded")

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

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

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

}
```

```ruby Client credentials (form fields)
require 'uri'
require 'net/http'

url = URI("https://api.paylocity.com/public/security/v1/token")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/x-www-form-urlencoded'

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

```java Client credentials (form fields)
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.paylocity.com/public/security/v1/token")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/x-www-form-urlencoded")
  .asString();
```

```php Client credentials (form fields)
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.paylocity.com/public/security/v1/token', [
  'form_params' => null,
  'headers' => [
    'Authorization' => 'Bearer <token>',
    'Content-Type' => 'application/x-www-form-urlencoded',
  ],
]);

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

```csharp Client credentials (form fields)
using RestSharp;

var client = new RestClient("https://api.paylocity.com/public/security/v1/token");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <token>");
request.AddHeader("Content-Type", "application/x-www-form-urlencoded");
IRestResponse response = client.Execute(request);
```

```swift Client credentials (form fields)
import Foundation

let headers = [
  "Authorization": "Bearer <token>",
  "Content-Type": "application/x-www-form-urlencoded"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.paylocity.com/public/security/v1/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()
```