# Frontline User Resource

The User resource represents a Twilio Frontline user who can log in to the Frontline application. Any user assigned to the Twilio Frontline application within your Identity Provider will be able to access Frontline.

## API Base URL

All URLs in the reference documentation use the following base URL:

```bash
https://frontline-api.twilio.com/v1
```

## User Properties

```json
{"type":"object","refName":"frontline.v1.user","modelName":"frontline_v1_user","properties":{"sid":{"type":"string","minLength":34,"maxLength":34,"pattern":"^US[0-9a-fA-F]{32}$","nullable":true,"description":"The unique string that we created to identify the User resource."},"identity":{"type":"string","nullable":true,"description":"The application-defined string that uniquely identifies the resource's User. This value is often a username or an email address, and is case-sensitive.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"friendly_name":{"type":"string","nullable":true,"description":"The string that you assigned to describe the User.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"avatar":{"type":"string","nullable":true,"description":"The avatar URL which will be shown in Frontline application."},"state":{"type":"string","enum":["active","deactivated"],"description":"Current state of this user. Can be either `active` or `deactivated` and defaults to `active`","refName":"user_enum_state_type","modelName":"user_enum_state_type"},"is_available":{"type":"boolean","nullable":true,"description":"Whether the User is available for new conversations. Defaults to `false` for new users."},"url":{"type":"string","format":"uri","nullable":true,"description":"An absolute API resource URL for this user."}}}
```

## Fetch a User

`GET https://frontline-api.twilio.com/v1/Users/{Sid}`

### Path parameters

```json
[{"name":"Sid","in":"path","description":"The SID of the User resource to fetch. This value can be either the `sid` or the `identity` of the User resource to fetch.","schema":{"type":"string"},"required":true}]
```

Fetch a User

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function fetchUser() {
  const user = await client.frontlineApi.v1
    .users("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    .fetch();

  console.log(user.sid);
}

fetchUser();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

user = client.frontline_api.v1.users(
    "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
).fetch()

print(user.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.FrontlineApi.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var user = await UserResource.FetchAsync(pathSid: "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        Console.WriteLine(user.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.frontlineapi.v1.User;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        User user = User.fetcher("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").fetch();

        System.out.println(user.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	resp, err := client.FrontlineV1.FetchUser("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$user = $twilio->frontlineApi->v1
    ->users("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->fetch();

print $user->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

user = @client
       .frontline_api
       .v1
       .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
       .fetch

puts user.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:frontline:v1:users:fetch \
   --sid USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
```

```bash
curl -X GET "https://frontline-api.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "identity": "john@example.com",
  "friendly_name": "John Doe",
  "avatar": "https://example.com/profile.png",
  "state": "active",
  "is_available": true,
  "url": "https://frontline-api.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## Update a User

`POST https://frontline-api.twilio.com/v1/Users/{Sid}`

### Path parameters

```json
[{"name":"Sid","in":"path","description":"The SID of the User resource to update. This value can be either the `sid` or the `identity` of the User resource to update.","schema":{"type":"string"},"required":true}]
```

### Request body parameters

```json
{"schema":{"type":"object","title":"UpdateUserRequest","properties":{"FriendlyName":{"type":"string","description":"The string that you assigned to describe the User.","x-twilio":{"pii":{"handling":"standard","deleteSla":30}}},"Avatar":{"type":"string","description":"The avatar URL which will be shown in Frontline application."},"State":{"type":"string","enum":["active","deactivated"],"description":"Current state of this user. Can be either `active` or `deactivated` and defaults to `active`","refName":"user_enum_state_type","modelName":"user_enum_state_type"},"IsAvailable":{"type":"boolean","description":"Whether the User is available for new conversations. Set to `false` to prevent User from receiving new inbound conversations if you are using [Pool Routing](/docs/frontline/handle-incoming-conversations#3-pool-routing)."}}},"examples":{"update":{"value":{"lang":"json","value":"{\n  \"State\": \"active\",\n  \"FriendlyName\": \"Name\",\n  \"Avatar\": \"https://example.com/avatar.png\",\n  \"IsAvailable\": true\n}","meta":"","code":"{\n  \"State\": \"active\",\n  \"FriendlyName\": \"Name\",\n  \"Avatar\": \"https://example.com/avatar.png\",\n  \"IsAvailable\": true\n}","tokens":[["{","#C9D1D9"],"\n  ",["\"State\"","#7EE787"],[":","#C9D1D9"]," ",["\"active\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"FriendlyName\"","#7EE787"],[":","#C9D1D9"]," ",["\"Name\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"Avatar\"","#7EE787"],[":","#C9D1D9"]," ",["\"https://example.com/avatar.png\"","#A5D6FF"],[",","#C9D1D9"],"\n  ",["\"IsAvailable\"","#7EE787"],[":","#C9D1D9"]," ",["true","#79C0FF"],"\n",["}","#C9D1D9"]],"annotations":[],"themeName":"github-dark","style":{"color":"#c9d1d9","background":"#0d1117"}}}},"encodingType":"application/x-www-form-urlencoded","conditionalParameterMap":{}}
```

Update a user

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function updateUser() {
  const user = await client.frontlineApi.v1
    .users("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    .update({
      avatar: "https://example.com/new-profile.png",
      friendlyName: "John Doe",
      isAvailable: true,
    });

  console.log(user.sid);
}

updateUser();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

user = client.frontline_api.v1.users(
    "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
).update(
    friendly_name="John Doe",
    avatar="https://example.com/new-profile.png",
    is_available=True,
)

print(user.sid)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.FrontlineApi.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var user = await UserResource.UpdateAsync(
            friendlyName: "John Doe",
            avatar: "https://example.com/new-profile.png",
            isAvailable: true,
            pathSid: "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        Console.WriteLine(user.Sid);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.frontlineapi.v1.User;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        User user = User.updater("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
                        .setFriendlyName("John Doe")
                        .setAvatar("https://example.com/new-profile.png")
                        .setIsAvailable(true)
                        .update();

        System.out.println(user.getSid());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	frontline "github.com/twilio/twilio-go/rest/frontline/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &frontline.UpdateUserParams{}
	params.SetFriendlyName("John Doe")
	params.SetAvatar("https://example.com/new-profile.png")
	params.SetIsAvailable(true)

	resp, err := client.FrontlineV1.UpdateUser("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.Sid != nil {
			fmt.Println(*resp.Sid)
		} else {
			fmt.Println(resp.Sid)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$user = $twilio->frontlineApi->v1
    ->users("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->update([
        "friendlyName" => "John Doe",
        "avatar" => "https://example.com/new-profile.png",
        "isAvailable" => true,
    ]);

print $user->sid;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

user = @client
       .frontline_api
       .v1
       .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
       .update(
         friendly_name: 'John Doe',
         avatar: 'https://example.com/new-profile.png',
         is_available: true
       )

puts user.sid
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:frontline:v1:users:update \
   --sid USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
   --friendly-name "John Doe" \
   --avatar https://example.com/new-profile.png \
   --is-available
```

```bash
curl -X POST "https://frontline-api.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
--data-urlencode "FriendlyName=John Doe" \
--data-urlencode "Avatar=https://example.com/new-profile.png" \
--data-urlencode "IsAvailable=true" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "identity": "john@example.com",
  "friendly_name": "John Doe",
  "avatar": "https://example.com/new-profile.png",
  "state": "active",
  "is_available": true,
  "url": "https://frontline-api.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```

## User Deactivation

A user can be deactivated by updating their state to deactivated. When a user is deactivated:

* All active sessions for that user will be invalidated, and the user will be logged out
* The user will be removed from any [pools](/docs/frontline/handle-incoming-conversations#3-pool-routing) they are a member of

> \[!WARNING]
>
> Deactivating a user by itself does not block a user from logging in to Frontline in the future. Before deactivating a Frontline user, their access to Frontline should be removed from your SSO provider. Once a user no longer has access to Frontline through your SSO provider, deactivating that user will invalidate any existing Frontline sessions from that user.

If a user's `state` has been deactivated but that user still has access to Frontline through your SSO provider, on their next login, that user's `state` will be updated to `active`

Deactivate a user

```js
// Download the helper library from https://www.twilio.com/docs/node/install
const twilio = require("twilio"); // Or, for ESM: import twilio from "twilio";

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
const accountSid = process.env.TWILIO_ACCOUNT_SID;
const authToken = process.env.TWILIO_AUTH_TOKEN;
const client = twilio(accountSid, authToken);

async function updateUser() {
  const user = await client.frontlineApi.v1
    .users("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    .update({ state: "deactivated" });

  console.log(user.state);
}

updateUser();
```

```python
# Download the helper library from https://www.twilio.com/docs/python/install
import os
from twilio.rest import Client

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = os.environ["TWILIO_ACCOUNT_SID"]
auth_token = os.environ["TWILIO_AUTH_TOKEN"]
client = Client(account_sid, auth_token)

user = client.frontline_api.v1.users(
    "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
).update(state="deactivated")

print(user.state)
```

```csharp
// Install the C# / .NET helper library from twilio.com/docs/csharp/install

using System;
using Twilio;
using Twilio.Rest.FrontlineApi.V1;
using System.Threading.Tasks;

class Program {
    public static async Task Main(string[] args) {
        // Find your Account SID and Auth Token at twilio.com/console
        // and set the environment variables. See http://twil.io/secure
        string accountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID");
        string authToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN");

        TwilioClient.Init(accountSid, authToken);

        var user = await UserResource.UpdateAsync(
            state: UserResource.StateTypeEnum.Deactivated,
            pathSid: "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");

        Console.WriteLine(user.State);
    }
}
```

```java
// Install the Java helper library from twilio.com/docs/java/install

import com.twilio.Twilio;
import com.twilio.rest.frontlineapi.v1.User;

public class Example {
    // Find your Account SID and Auth Token at twilio.com/console
    // and set the environment variables. See http://twil.io/secure
    public static final String ACCOUNT_SID = System.getenv("TWILIO_ACCOUNT_SID");
    public static final String AUTH_TOKEN = System.getenv("TWILIO_AUTH_TOKEN");

    public static void main(String[] args) {
        Twilio.init(ACCOUNT_SID, AUTH_TOKEN);
        User user = User.updater("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX").setState(User.StateType.DEACTIVATED).update();

        System.out.println(user.getState());
    }
}
```

```go
// Download the helper library from https://www.twilio.com/docs/go/install
package main

import (
	"fmt"
	"github.com/twilio/twilio-go"
	frontline "github.com/twilio/twilio-go/rest/frontline/v1"
	"os"
)

func main() {
	// Find your Account SID and Auth Token at twilio.com/console
	// and set the environment variables. See http://twil.io/secure
	// Make sure TWILIO_ACCOUNT_SID and TWILIO_AUTH_TOKEN exists in your environment
	client := twilio.NewRestClient()

	params := &frontline.UpdateUserParams{}
	params.SetState("deactivated")

	resp, err := client.FrontlineV1.UpdateUser("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
		params)
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	} else {
		if resp.State != nil {
			fmt.Println(resp.State)
		} else {
			fmt.Println(resp.State)
		}
	}
}
```

```php
<?php

// Update the path below to your autoload.php,
// see https://getcomposer.org/doc/01-basic-usage.md
require_once "/path/to/vendor/autoload.php";

use Twilio\Rest\Client;

// Find your Account SID and Auth Token at twilio.com/console
// and set the environment variables. See http://twil.io/secure
$sid = getenv("TWILIO_ACCOUNT_SID");
$token = getenv("TWILIO_AUTH_TOKEN");
$twilio = new Client($sid, $token);

$user = $twilio->frontlineApi->v1
    ->users("USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
    ->update(["state" => "deactivated"]);

print $user->state;
```

```ruby
# Download the helper library from https://www.twilio.com/docs/ruby/install
require 'twilio-ruby'

# Find your Account SID and Auth Token at twilio.com/console
# and set the environment variables. See http://twil.io/secure
account_sid = ENV['TWILIO_ACCOUNT_SID']
auth_token = ENV['TWILIO_AUTH_TOKEN']
@client = Twilio::REST::Client.new(account_sid, auth_token)

user = @client
       .frontline_api
       .v1
       .users('USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX')
       .update(state: 'deactivated')

puts user.state
```

```bash
# Install the twilio-cli from https://twil.io/cli

twilio api:frontline:v1:users:update \
   --sid USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX \
   --state deactivated
```

```bash
curl -X POST "https://frontline-api.twilio.com/v1/Users/USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX" \
--data-urlencode "State=deactivated" \
-u $TWILIO_ACCOUNT_SID:$TWILIO_AUTH_TOKEN
```

```json
{
  "sid": "USXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
  "identity": "john@example.com",
  "friendly_name": "John Doe",
  "avatar": "https://example.com/profile.png",
  "state": "deactivated",
  "is_available": true,
  "url": "https://frontline-api.twilio.com/v1/Users/USaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
}
```
