> ## Documentation Index
> Fetch the complete documentation index at: https://docs-staging-quickstart-revamp.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> Learn to define organization behavior within applications for Auth0's Organizations feature.

# Define Organization Behavior

When representing your application in Auth0, you can specify what types of users the application should support. Some applications support individuals logging in with personal accounts, while others are intended for use by members of [organizations](/docs/manage-users/organizations/organizations-overview). Some should support both. This is known as organization behavior and can be set for each application that you connect to Auth0.

For example, your application could have:

* A generic marketing landing page that has a **Log in** button that takes your users to the Auth0 login flow without an Organization.
* A separate URL for each of your B2B customers (e.g., Acme users go to `acme.yourcompany.com`) that redirects users to Auth0 with an Organization, so that your users see Acme’s <Tooltip tip="Single Sign-On (SSO): Service that, after a user logs into one applicaton, automatically logs that user in to other applications." cta="View Glossary" href="/docs/glossary?term=SSO">SSO</Tooltip> Login button.

You can define Organization behavior to allow either of these scenarios. Additionally, you can configure Organization behavior such that if your application requires that an Organization be provided but your user accidentally is sent to Auth0 without an organization, they would see a prompt that would allow them to enter the name of their organization.

You can define organization behavior using either the <Tooltip tip="Management API: A product to allow customers to perform administrative tasks." cta="View Glossary" href="/docs/glossary?term=Auth0+Dashboard">Auth0 Dashboard</Tooltip> or the <Tooltip tip="Auth0 Dashboard: Auth0's main product to configure your services." cta="View Glossary" href="/docs/glossary?term=Management+API">Management API</Tooltip>.

## Auth0 Dashboard

To define organization behavior via the Auth0 Dashboard:

1. Navigate to [Auth0 Dashboard > Applications](https://manage.auth0.com/#/applications), and select the application for which you want to configure organizations.
2. Switch to the Login Experience view and configure the appropriate settings:

<table class="table">
  <thead>
    <tr>
      <th><strong>Field</strong></th>
      <th><strong>Description</strong></th>
      <th><strong>API Mapping</strong></th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><strong>Type of Users</strong></td>

      <td>
        Determines which category of users can log in to your application.<br /><br />
        Options include:

        <ul>
          <li>
            <strong>Individuals</strong>: Users can sign up with a personal account and log directly in to your application. Individual users cannot log in using an Organization.
          </li>

          <li>
            <strong>Business Users</strong>: Users must be a member of an Organization in order to log in. When selected, you must either provide an Organization when you redirect users to the <code>/authorize</code> endpoint or set your Login Flow to Prompt for Organization.
          </li>

          <li>
            <strong>Both</strong>: Users can log in as an Organization member or sign up with a personal account.
          </li>
        </ul>
      </td>

      <td>
        <strong>Type of Users</strong> maps to <code>organization\_usage</code><br /><br />
        Options:

        <ul>
          <li><strong>Individuals</strong> maps to <code>deny</code></li>
          <li><strong>Business Users</strong> maps to <code>require</code></li>
          <li><strong>Both</strong> maps to <code>allow</code></li>
        </ul>
      </td>
    </tr>

    <tr>
      <td><strong>Login Flow</strong></td>

      <td>
        Determines the initial login prompt presented to users when they access your application. You can only configure this field if Type of Users is set to Businsess Users or Both.<br /><br />
        Options include:

        <ul>
          <li>
            <strong>Prompt for Credentials</strong>: Users are first asked to provide their login credentials. After logging in, users can select their Organization.
          </li>

          <li>
            <strong>Prompt for Organization</strong>: Users are first asked to select their Organization. Then, they can provide their credentials to log in. You can only use this option if you set Type of Users to Business Users.
          </li>

          <li>
            <strong>No Prompt</strong>: Auth0 does not dictate which login prompt is given to users. Instead, your application is responsible for sending the required parameters to Auth0 to display the appropriate prompt.
          </li>
        </ul>
      </td>

      <td>
        <strong>Login Flow</strong> maps to <code>organization\_require\_behavior</code><br /><br />
        Options:

        <ul>
          <li><strong>Prompt for Credentials</strong> maps to <code>post\_login\_prompt</code></li>
          <li><strong>Prompt for Organization</strong> maps to <code>pre\_login\_prompt</code></li>
          <li><strong>No Prompt</strong> maps to <code>no\_prompt</code></li>
        </ul>
      </td>
    </tr>
  </tbody>
</table>

3. Select **Save changes**.

## Management API

Make a `PATCH` call to the [Update a Client endpoint](https://auth0.com/docs/api/management/v2#!/Clients/patch_clients_by_id). Be sure to replace `client_id`, `mgmt_api_access_token`, `organization_usage`, and `organization_require_behavior` placeholder values with your <Tooltip tip="Client ID: Identification value given to your registered resource from Auth0." cta="View Glossary" href="/docs/glossary?term=client+ID">client ID</Tooltip>, Management API <Tooltip tip="Client ID: Identification value given to your registered resource from Auth0." cta="View Glossary" href="/docs/glossary?term=Access+Token">Access Token</Tooltip>, organization use option, and organization behavior option, respectively.

<CodeGroup>
  ```bash cURL lines
  curl --request PATCH \
    --url 'https://{yourDomain}/api/v2/clients/CLIENT_ID' \
    --header 'authorization: Bearer MGMT_API_ACCESS_TOKEN' \
    --header 'cache-control: no-cache' \
    --header 'content-type: application/json' \
    --data '{ "organization_usage": "ORG_USAGE", "organization_require_behavior": "ORG_REQUIRE_BEHAVIOR" }'
  ```

  ```csharp C# lines
  var client = new RestClient("https://{yourDomain}/api/v2/clients/CLIENT_ID");
  var request = new RestRequest(Method.PATCH);
  request.AddHeader("content-type", "application/json");
  request.AddHeader("authorization", "Bearer MGMT_API_ACCESS_TOKEN");
  request.AddHeader("cache-control", "no-cache");
  request.AddParameter("application/json", "{ \"organization_usage\": \"ORG_USAGE\", \"organization_require_behavior\": \"ORG_REQUIRE_BEHAVIOR\" }", ParameterType.RequestBody);
  IRestResponse response = client.Execute(request);
  ```

  ```go Go lines expandable
  package main

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

  func main() {

  	url := "https://{yourDomain}/api/v2/clients/CLIENT_ID"

  	payload := strings.NewReader("{ \"organization_usage\": \"ORG_USAGE\", \"organization_require_behavior\": \"ORG_REQUIRE_BEHAVIOR\" }")

  	req, _ := http.NewRequest("PATCH", url, payload)

  	req.Header.Add("content-type", "application/json")
  	req.Header.Add("authorization", "Bearer MGMT_API_ACCESS_TOKEN")
  	req.Header.Add("cache-control", "no-cache")

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

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

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

  }
  ```

  ```java Java lines
  HttpResponse<String> response = Unirest.patch("https://{yourDomain}/api/v2/clients/CLIENT_ID")
    .header("content-type", "application/json")
    .header("authorization", "Bearer MGMT_API_ACCESS_TOKEN")
    .header("cache-control", "no-cache")
    .body("{ \"organization_usage\": \"ORG_USAGE\", \"organization_require_behavior\": \"ORG_REQUIRE_BEHAVIOR\" }")
    .asString();
  ```

  ```javascript Node.JS lines
  var axios = require("axios").default;

  var options = {
    method: 'PATCH',
    url: 'https://{yourDomain}/api/v2/clients/CLIENT_ID',
    headers: {
      'content-type': 'application/json',
      authorization: 'Bearer MGMT_API_ACCESS_TOKEN',
      'cache-control': 'no-cache'
    },
    data: {
      organization_usage: 'ORG_USAGE',
      organization_require_behavior: 'ORG_REQUIRE_BEHAVIOR'
    }
  };

  axios.request(options).then(function (response) {
    console.log(response.data);
  }).catch(function (error) {
    console.error(error);
  });
  ```

  ```obj-c Obj-C lines expandable
  #import <Foundation/Foundation.h>

  NSDictionary *headers = @{ @"content-type": @"application/json",
                             @"authorization": @"Bearer MGMT_API_ACCESS_TOKEN",
                             @"cache-control": @"no-cache" };
  NSDictionary *parameters = @{ @"organization_usage": @"ORG_USAGE",
                                @"organization_require_behavior": @"ORG_REQUIRE_BEHAVIOR" };

  NSData *postData = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil];

  NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"https://{yourDomain}/api/v2/clients/CLIENT_ID"]
                                                         cachePolicy:NSURLRequestUseProtocolCachePolicy
                                                     timeoutInterval:10.0];
  [request setHTTPMethod:@"PATCH"];
  [request setAllHTTPHeaderFields:headers];
  [request setHTTPBody:postData];

  NSURLSession *session = [NSURLSession sharedSession];
  NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
                                              completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
                                                  if (error) {
                                                      NSLog(@"%@", error);
                                                  } else {
                                                      NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
                                                      NSLog(@"%@", httpResponse);
                                                  }
                                              }];
  [dataTask resume];
  ```

  ```php PHP lines expandable
  $curl = curl_init();

  curl_setopt_array($curl, [
    CURLOPT_URL => "https://{yourDomain}/api/v2/clients/CLIENT_ID",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "PATCH",
    CURLOPT_POSTFIELDS => "{ \"organization_usage\": \"ORG_USAGE\", \"organization_require_behavior\": \"ORG_REQUIRE_BEHAVIOR\" }",
    CURLOPT_HTTPHEADER => [
      "authorization: Bearer MGMT_API_ACCESS_TOKEN",
      "cache-control: no-cache",
      "content-type: application/json"
    ],
  ]);

  $response = curl_exec($curl);
  $err = curl_error($curl);

  curl_close($curl);

  if ($err) {
    echo "cURL Error #:" . $err;
  } else {
    echo $response;
  }
  ```

  ```python Python lines
  import http.client

  conn = http.client.HTTPSConnection("")

  payload = "{ \"organization_usage\": \"ORG_USAGE\", \"organization_require_behavior\": \"ORG_REQUIRE_BEHAVIOR\" }"

  headers = {
      'content-type': "application/json",
      'authorization': "Bearer MGMT_API_ACCESS_TOKEN",
      'cache-control': "no-cache"
      }

  conn.request("PATCH", "/{yourDomain}/api/v2/clients/CLIENT_ID", payload, headers)

  res = conn.getresponse()
  data = res.read()

  print(data.decode("utf-8"))
  ```

  ```ruby Ruby lines
  require 'uri'
  require 'net/http'
  require 'openssl'

  url = URI("https://{yourDomain}/api/v2/clients/CLIENT_ID")

  http = Net::HTTP.new(url.host, url.port)
  http.use_ssl = true
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE

  request = Net::HTTP::Patch.new(url)
  request["content-type"] = 'application/json'
  request["authorization"] = 'Bearer MGMT_API_ACCESS_TOKEN'
  request["cache-control"] = 'no-cache'
  request.body = "{ \"organization_usage\": \"ORG_USAGE\", \"organization_require_behavior\": \"ORG_REQUIRE_BEHAVIOR\" }"

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

  ```swift Swift lines expandable
  import Foundation

  let headers = [
    "content-type": "application/json",
    "authorization": "Bearer MGMT_API_ACCESS_TOKEN",
    "cache-control": "no-cache"
  ]
  let parameters = [
    "organization_usage": "ORG_USAGE",
    "organization_require_behavior": "ORG_REQUIRE_BEHAVIOR"
  ] as [String : Any]

  let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

  let request = NSMutableURLRequest(url: NSURL(string: "https://{yourDomain}/api/v2/clients/CLIENT_ID")! as URL,
                                          cachePolicy: .useProtocolCachePolicy,
                                      timeoutInterval: 10.0)
  request.httpMethod = "PATCH"
  request.allHTTPHeaderFields = headers
  request.httpBody = postData as Data

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

  dataTask.resume()
  ```
</CodeGroup>

<table class="table">
  <thead>
    <tr>
      <th>Value</th>
      <th>Description</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><code>CLIENT\_ID</code></td>
      <td>ID of the application for which you want to add organization behavior.</td>
    </tr>

    <tr>
      <td><code>MGMT\_API\_ACCESS\_TOKEN</code></td>

      <td>
        <a href="/docs/secure/tokens/access-tokens/management-api-access-tokens">Access Tokens for the Management API</a> with the scope <code>update:clients</code>.
      </td>
    </tr>

    <tr>
      <td><code>ORGANIZATION\_USAGE</code></td>

      <td>
        Dictates whether your application can support users logging into an organization. Options include:

        <ul>
          <li><code>deny</code>: (Default) Users cannot log in using an organization.</li>
          <li><code>allow</code>: Users can log in with or without an Organization. When selected, you must provide an organization when you redirect users to the <code>/authorize</code> endpoint.</li>
          <li><code>require</code>: Users must log in using an organization. When selected, you must either provide an organization when you redirect users to the <code>/authorize</code> endpoint or set <code>organization\_require\_behavior</code> to <code>pre\_login\_prompt</code> to allow users to choose an organization before they log in.</li>
        </ul>
      </td>
    </tr>

    <tr>
      <td><code>ORGANIZATION\_REQUIRE\_BEHAVIOR</code></td>

      <td>
        Determines the Login Flow presented to users accessing your application. Only applicable when <code>organization\_usage</code> is set to <code>require</code> or <code>allow</code>.<br /><br />Options include:

        <ul>
          <li><code>no\_prompt</code>: (Default) Display no prompt. Requests without a valid organization parameter are rejected.</li>
          <li><code>pre\_login\_prompt</code>: Prompt users to select an Organization before they can log in. You can only use this option if <code>organization\_usage</code> is set to <code>require</code>.</li>
          <li><code>post\_login\_prompt</code>: Prompt users to log in with their credentials. After they log in, prompt users to select their Organization.</li>
        </ul>
      </td>
    </tr>
  </tbody>
</table>

### Response status codes

Possible response status codes are as follows:

| Status code | Error code                | Message                                                                                                                                              | Cause                                                                              |
| ----------- | ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------- |
| `200`       |                           | Client successfully updated.                                                                                                                         |                                                                                    |
| `400`       | `invalid_uri`             | Invalid request URI. The message will vary depending on the cause.                                                                                   | The path is not valid.                                                             |
| `400`       | `invalid_body`            | Invalid request body. The message will vary depending on the cause.                                                                                  | The request payload is not valid.                                                  |
| `401`       |                           | Invalid token.                                                                                                                                       |                                                                                    |
| `401`       |                           | Client is not global.                                                                                                                                |                                                                                    |
| `401`       |                           | Invalid signature received for JSON Web Token validation.                                                                                            |                                                                                    |
| `403`       | `insufficient_scope`      | Insufficient scope; expected any of: `update:clients`.                                                                                               | Tried to read/write a field that is not allowed with provided bearer token scopes. |
| `403`       | `insufficient_scope`      | Some fields cannot be updated with the permissions granted by the bearer token scopes. The message will vary depending on the fields and the scopes. | Tried to read/write a field that is not allowed with provided bearer token scopes. |
| `403`       | `operation_not_supported` | The account is not allowed to perform this operation.                                                                                                | The account is not allowed to perform this operation.                              |
| `404`       | `inexistent_client`       | Client not found.                                                                                                                                    | Inexistent resource. Specified application does not exist.                         |
| `429`       |                           | Too many requests. Check the X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset headers.                                                 |                                                                                    |
