> This page is for Spending Accounts.

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

# Get Cost Center Codes

GET https://api.paylocity.com/apiHub/corehr/v1/companies/{companyId}/costCentersAndLevels

**Summary Description**

The GET Cost Center List by Company ID endpoint, retrieves a comprehensive list of Cost Center from the Paylocity system with each call. To use this endpoint, the Paylocity “costCentersAndLevels” parameter must be specified. Cost centers are distinct entities or divisions within an organization that bear expenses as a result of their activities. These cost centers are crucial for monitoring and controlling expenses, allocating funds, and evaluating the efficiency of various departments within the firm. Cost centers are predominantly employed in managerial accounting and financial management to apportion expenses and evaluate resource utilization. Typical instances of cost centers encompass production departments, marketing teams, research and development units, and administrative offices.

**Use Cases**

- Cost allocation refers to the process of assigning costs that have been incurred by a specific cost center to that same center. The costs encompass staff remuneration, utility bills, rental fees, supplies, and any additional expenses related to the activities of the cost center.
- Budgeting: Cost centers are essential in the process of creating a budget. Organizations distribute budgets among several cost centers and then compare the actual expenses of each center to their allocated budget. This facilitates cost management and performance assessment. 
- Performance Evaluation: Cost centers are assessed according to their capacity to effectively control costs while attaining their goals. Performance metrics may encompass indicators such as the cost incurred for each unit of output, the cost incurred for each employee, or other pertinent measures. 
- Cost Reporting: Organizations frequently produce reports for individual cost centers, providing a comprehensive breakdown of their expenditures and operational effectiveness. Management utilizes these reports to evaluate the financial well-being and effectiveness of each cost center.

**Note**

- A company cannot delete Cost Centers. The Cost Center is editable after use, but the chosen Code for the Cost Center is permanent.
- To ensure cross-product compatibility, Cost Center Codes should not contain leading zeros or special characters. Cost Center codes must be numeric only if employees transfer using time clocks or kiosk tablets.
- A Country selection is necessary before being able to enter information into the Zip and State fields when selecting the Override Company Check Printing Address option.


Reference: https://paylocity.ferndocs.com/spending-accounts/api-reference/latest/paylocity-ap-is/company-level-information-cost-center/get-cost-center-codes

## Authentication

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

## Request

### Path parameters

- `companyId` (string, required)

### Headers

- `testMode` (boolean, optional) — If true all responses are mocked and generated randomly.
- `Accept` (string, optional)

## Response

### 200

Successful response

## Examples

**Response**

```json
{}
```

**SDK Code**

```python
import requests

url = "https://api.paylocity.com/apiHub/corehr/v1/companies/companyId/costCentersAndLevels"

headers = {
    "testMode": "true",
    "Accept": "application/json",
    "Authorization": "Bearer <token>"
}

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

print(response.json())
```

```javascript
const url = 'https://api.paylocity.com/apiHub/corehr/v1/companies/companyId/costCentersAndLevels';
const options = {
  method: 'GET',
  headers: {testMode: 'true', Accept: 'application/json', Authorization: 'Bearer <token>'}
};

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

```go
package main

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

func main() {

	url := "https://api.paylocity.com/apiHub/corehr/v1/companies/companyId/costCentersAndLevels"

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

	req.Header.Add("testMode", "true")
	req.Header.Add("Accept", "application/json")
	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
require 'uri'
require 'net/http'

url = URI("https://api.paylocity.com/apiHub/corehr/v1/companies/companyId/costCentersAndLevels")

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

request = Net::HTTP::Get.new(url)
request["testMode"] = 'true'
request["Accept"] = 'application/json'
request["Authorization"] = 'Bearer <token>'

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

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

HttpResponse<String> response = Unirest.get("https://api.paylocity.com/apiHub/corehr/v1/companies/companyId/costCentersAndLevels")
  .header("testMode", "true")
  .header("Accept", "application/json")
  .header("Authorization", "Bearer <token>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://api.paylocity.com/apiHub/corehr/v1/companies/companyId/costCentersAndLevels', [
  'headers' => [
    'Accept' => 'application/json',
    'Authorization' => 'Bearer <token>',
    'testMode' => 'true',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://api.paylocity.com/apiHub/corehr/v1/companies/companyId/costCentersAndLevels");
var request = new RestRequest(Method.GET);
request.AddHeader("testMode", "true");
request.AddHeader("Accept", "application/json");
request.AddHeader("Authorization", "Bearer <token>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "testMode": "true",
  "Accept": "application/json",
  "Authorization": "Bearer <token>"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://api.paylocity.com/apiHub/corehr/v1/companies/companyId/costCentersAndLevels")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
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()
```