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

# Get Users By State

GET https://www.crehana.com/api/v5/rest/org/{organization_slug}/users/state/

Returns a paginated list of users from the organization filtered by state. Supported values: INACTIVE, DELETED.

Reference: https://developer.crehana.com/api-reference/endpoints/users/get-users-by-state

## Authentication

- `Api-Key` header (required) — API key of the organization. Always sent together with the `Secret-Access` header.

## Servers

- `https://www.crehana.com` (Production, default)
- `https://qa.creha.co` (QA)

## Request

### Path parameters

- `organization_slug` (string, required)

### Query parameters

- `cursor` (string, optional)
- `limit` (integer, optional, default: 10)
- `search` (string, optional)
- `state` (string, optional, default: INACTIVE)

## Response

### 200

Successful Response

- `message` (string, required) — Message of the response
- `code` (string, required) — Internal code of the response
- `datetime` (string, required) — Datetime of the API in ISO Format
- `data` (list of RetrieveUser, optional)
- `next_cursor` (string, optional)
- `has_next_page` (boolean, optional)
- `total_count` (integer, optional)

## Errors

### 422 Unprocessable Entity Error

Validation Error

- `detail` (list of ValidationError, optional)

## Types

### RetrieveUser

- `id` (integer, optional)
- `first_name` (string, optional)
- `last_name` (string, optional)
- `email` (string, optional)
- `area_id` (integer, optional)
- `position_id` (integer, optional)
- `position_category_id` (integer, optional)
- `role` (string, optional)
- `headquarter_id` (integer, optional)
- `boss_id` (integer, optional)
- `document_type` (string, optional)
- `document` (string, optional)
- `gender` (string, optional)
- `civil_status` (string, optional)
- `phone_1` (string, optional)
- `phone_2` (string, optional)
- `address` (string, optional)
- `city` (string, optional)
- `country` (string, optional)
- `deactivation_date` (string, optional)
- `incorporation_date` (date, optional)
- `status` (string, optional)
- `invitation_sent` (boolean, optional)
- `custom_fields` (list of apps__users__outputs__CustomField, optional)
- `birth_date` (date, optional)

### ValidationError

- `loc` (list of ValidationErrorLocItems, required)
- `msg` (string, required)
- `type` (string, required)

### apps__users__outputs__CustomField

- `id` (integer, optional)
- `value` (string, optional)
- `choice_id` (integer, optional)

### ValidationErrorLocItems

## Examples

**Response**

```json
{
  "message": "Users retrieved correctly.",
  "code": "user-001",
  "datetime": "2021-10-08T16:23:05.000000",
  "data": [
    {
      "id": 1,
      "first_name": "John",
      "last_name": "Doe",
      "email": "jhondoe@example.com",
      "area_id": 1,
      "position_id": 1,
      "position_category_id": 1,
      "role": "Admin",
      "headquarter_id": 1,
      "boss_id": 2,
      "document_type": "passport",
      "document": "A1234567",
      "gender": "male",
      "civil_status": "single",
      "phone_1": "123456789",
      "phone_2": "987654321",
      "address": "Calle Falsa 123",
      "city": "Bogota",
      "country": "Colombia",
      "deactivation_date": "2022-12-31",
      "incorporation_date": "2021-12-31",
      "status": "ACTIVE",
      "invitation_sent": true,
      "custom_fields": [
        {
          "id": 1,
          "value": "Value 1",
          "choice_id": 1
        }
      ]
    },
    {
      "id": 2,
      "first_name": "Jane",
      "last_name": "Doe",
      "email": "janedoe@example.com",
      "area_id": 2,
      "position_id": 2,
      "position_category_id": 2,
      "role": "User",
      "headquarter_id": 2,
      "boss_id": 3,
      "document_type": "id",
      "document": "B7654321",
      "gender": "female",
      "civil_status": "married",
      "phone_1": "987654321",
      "phone_2": "123456789",
      "address": "Avenida Siempre Viva 742",
      "city": "Medellin",
      "country": "Colombia",
      "deactivation_date": "2023-12-31",
      "incorporation_date": "2020-12-31",
      "status": "PENDING",
      "invitation_sent": false,
      "custom_fields": [
        {
          "id": 2,
          "value": "Value 2",
          "choice_id": 2
        }
      ]
    }
  ],
  "next_cursor": "YXJyYXljb25uZWN0aW9uOjA=",
  "has_next_page": true,
  "total_count": 4
}
```

**SDK Code**

```python
import requests

url = "https://www.crehana.com/api/v5/rest/org/organization_slug/users/state/"

headers = {
    "Secret-Access": "Secret-Access",
    "Api-Key": "<apiKey>"
}

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

print(response.json())
```

```javascript
const url = 'https://www.crehana.com/api/v5/rest/org/organization_slug/users/state/';
const options = {
  method: 'GET',
  headers: {'Secret-Access': 'Secret-Access', 'Api-Key': '<apiKey>'}
};

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://www.crehana.com/api/v5/rest/org/organization_slug/users/state/"

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

	req.Header.Add("Secret-Access", "Secret-Access")
	req.Header.Add("Api-Key", "<apiKey>")

	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://www.crehana.com/api/v5/rest/org/organization_slug/users/state/")

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

request = Net::HTTP::Get.new(url)
request["Secret-Access"] = 'Secret-Access'
request["Api-Key"] = '<apiKey>'

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://www.crehana.com/api/v5/rest/org/organization_slug/users/state/")
  .header("Secret-Access", "Secret-Access")
  .header("Api-Key", "<apiKey>")
  .asString();
```

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

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://www.crehana.com/api/v5/rest/org/organization_slug/users/state/', [
  'headers' => [
    'Api-Key' => '<apiKey>',
    'Secret-Access' => 'Secret-Access',
  ],
]);

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

```csharp
using RestSharp;

var client = new RestClient("https://www.crehana.com/api/v5/rest/org/organization_slug/users/state/");
var request = new RestRequest(Method.GET);
request.AddHeader("Secret-Access", "Secret-Access");
request.AddHeader("Api-Key", "<apiKey>");
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Secret-Access": "Secret-Access",
  "Api-Key": "<apiKey>"
]

let request = NSMutableURLRequest(url: NSURL(string: "https://www.crehana.com/api/v5/rest/org/organization_slug/users/state/")! 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()
```