Create Organization - Stytch Docs
Documentation Index
Fetch the complete documentation index at: /docs/llms.txt
Use this file to discover all available pages before exploring further.
// POST /v1/b2b/organizations
const stytch = require('stytch');
const client = new stytch.B2BClient({
project_id: '${projectId}',
secret: '${secret}',
});
const params = {
organization_name: "Example Org Inc.",
organization_slug: "example-org",
organization_external_id: "my-external-id",
};
client.Organizations.Create(params)
.then(resp => { console.log(resp) })
.catch(err => { console.log(err) });
// POST /v1/b2b/organizations
package main
import (
"context"
"log"
"github.com/stytchauth/stytch-go/v18/stytch/b2b/b2bstytchapi"
"github.com/stytchauth/stytch-go/v18/stytch/b2b/organizations"
)
func main() {
client, err := b2bstytchapi.NewClient(
"${projectId}",
"${secret}",
)
if err != nil {
log.Fatalf("error instantiating client: %v", err)
}
params := &organizations.CreateParams{
OrganizationName: "Example Org Inc.",
OrganizationSlug: "example-org",
OrganizationExternalID: "my-external-id",
}
resp, err := client.Organizations.Create(context.Background(), params)
if err != nil {
log.Fatalf("error in method call: %v", err)
}
log.Println(resp)
}
// POST /v1/b2b/organizations
package com.example;
import com.stytch.java.b2b.models.organizations.CreateRequest;
import com.stytch.java.b2b.StytchB2BClient;
import com.stytch.java.common.StytchResult;
public class Main {
public static void main(String[] args) {
StytchB2BClient.configure("${projectId}", "${secret}");
CreateRequest params = new CreateRequest();
params.setOrganizationName("Example Org Inc.");
params.setOrganizationSlug("example-org");
params.setOrganizationExternalId("my-external-id");
Object result = StytchB2BClient.getOrganizations().create(params);
if (result instanceof StytchResult.Success) {
System.out.println(((StytchResult.Success) result).getValue());
} else {
System.out.println(((StytchResult.Error) result).getException());
}
}
}
// POST /v1/b2b/organizations
package com.example
import com.stytch.java.b2b.StytchB2BClient
import com.stytch.java.b2b.models.organizations.CreateRequest
fun main() {
StytchB2BClient.configure(
projectId = "${projectId}",
secret = "${secret}",
)
when (
val result =
StytchB2BClient.organizations.create(
CreateRequest(
organizationName = "Example Org Inc.",
organizationSlug = "example-org",
organizationExternalId = "my-external-id",
),
)
) {
is StytchResult.Success -> println(result.value)
is StytchResult.Error -> println(result.exception)
}
}
// POST /v1/b2b/organizations
const stytch = require('stytch');
const client = new stytch.B2BClient({
project_id: '${projectId}',
secret: '${secret}',
});
const params = {
organization_name: "Example Org Inc.",
organization_slug: "example-org",
organization_external_id: "my-external-id",
};
client.organizations.create(params)
.then(resp => { console.log(resp) })
.catch(err => { console.log(err) });
$response = $client->organizations->create([
'organization_name' => 'Example Org Inc.',
'organization_slug' => 'example-org',
'organization_external_id' => 'my-external-id',
]);
# POST /v1/b2b/organizations
from stytch import B2BClient
client = B2BClient(
project_id="${projectId}",
secret="${secret}",
)
resp = client.organizations.create(
organization_name="Example Org Inc.",
organization_slug="example-org",
organization_external_id="my-external-id",
)
print(resp)
# frozen_string_literal: true
# POST /v1/b2b/organizations
require 'stytch'
client = StytchB2B::Client.new(
project_id: "${projectId}",
secret: "${secret}"
)
resp = client.organizations.create(
organization_name: "Example Org Inc.",
organization_slug: "example-org",
organization_external_id: "my-external-id"
)
puts resp
// POST /v1/b2b/organizations
use stytch::b2b::client::Client;
use stytch::b2b::organizations::CreateRequest;
fn main() {
let client = Client::new("${projectId}", "${secret}").unwrap();
let resp = client.organizations.create(
CreateRequest{
organization_name: "Example Org Inc.",
organization_slug: Some(String::from("example-org")),
organization_external_id: Some(String::from("my-external-id")),
..Default::default()
}
).await;
println!("The response is {:?}", resp);
}
# POST /v1/b2b/organizations
curl --request POST \
--url https://test.stytch.com/v1/b2b/organizations \
-u '${projectId}:${secret}' \
-H 'Content-Type: application/json' \
-d '{
"organization_name": "Example Org Inc.",
"organization_slug": "example-org",
"organization_external_id": "my-external-id"
}'
Creates an Organization
An organization_name and a unique organization_slug are required. If no Organization authentication parameters are passed in, email_invites defaults to ALL_ALLOWED allowing the Organization to add Members. If some authentication parameters are passed but email_invites is omitted, it defaults to NOT_ALLOWED. Learn more about fields like email_jit_provisioning, email_invites, sso_jit_provisioning, etc., and their behavior in the Organization authentication settings guide.
Authorizations
Authorization
string
header
required
Basic authentication header of the form Basic <encoded-value>, where <encoded-value> is the base64-encoded string username:password.
Body
application/json
Request type
| Field | Type | Description |
|---|---|---|
| organization_name | string | The name of the Organization. Must be between 1 and 128 characters in length. |
| organization_slug | string | The unique URL slug of the Organization. The slug only accepts alphanumeric characters and the following reserved characters: -``.``_``~. Must be between 2 and 128 characters in length. Wherever an organization_id is expected in a path or request parameter, you may also use the organization_slug as a convenience. |
| organization_logo_url | string | The image URL of the Organization logo. |
| trusted_metadata | object | An arbitrary JSON object for storing application-specific data or identity-provider-specific data. |
| organization_external_id | string | An identifier that can be used in API calls wherever a organization_id is expected. This is a string consisting of alphanumeric, ., _, -, or ` |
| sso_jit_provisioning | string | The authentication setting that controls the JIT provisioning of Members when authenticating via SSO. The accepted values are:ALL_ALLOWED – the default setting, new Members will be automatically provisioned upon successful authentication via any of the Organization's sso_active_connections. |
RESTRICTED – only new Members with SSO logins that comply with sso_jit_provisioning_allowed_connections can be provisioned upon authentication. |
||
NOT_ALLOWED – disable JIT provisioning via SSO. |
||
| email_allowed_domains | string[] | An array of email domains that allow invites or JIT provisioning for new Members. This list is enforced when either email_invites or email_jit_provisioning is set to RESTRICTED. |
Common domains such as gmail.com are not allowed. See the common email domains resource for the full list.
| email_jit_provisioning | string | The authentication setting that controls how a new Member can be provisioned by authenticating via Email Magic Link or OAuth. The accepted values are:RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be provisioned upon authentication via Email Magic Link or OAuth.
NOT_ALLOWED – the default setting, disables JIT provisioning via Email Magic Link and OAuth. |
| email_invites | string | The authentication setting that controls how a new Member can be invited to an organization by email. The accepted values are:ALL_ALLOWED – any new Member can be invited to join via email.
RESTRICTED – only new Members with verified emails that comply with email_allowed_domains can be invited via email.
NOT_ALLOWED – disable email invites. |
| auth_methods | string | The setting that controls which authentication methods can be used by Members of an Organization. The accepted values are:ALL_ALLOWED – the default setting which allows all authentication methods to be used.
RESTRICTED – only methods that comply with allowed_auth_methods can be used for authentication. This setting does not apply to Members with is_breakglass set to true. |
| allowed_auth_methods | string[] | An array of allowed authentication methods. This list is enforced when auth_methods is set to RESTRICTED.
The list's accepted values are: sso, magic_link, email_otp, password, google_oauth, microsoft_oauth, slack_oauth, github_oauth, and hubspot_oauth. |
| mfa_policy | string | The setting that controls the MFA policy for all Members in the Organization. The accepted values are:REQUIRED_FOR_ALL – All Members within the Organization will be required to complete MFA every time they wish to log in. However, any active Session that existed prior to this setting change will remain valid.
OPTIONAL – The default value. The Organization does not require MFA by default for all Members. Members will be required to complete MFA only if their mfa_enrolled status is set to true. |
Response
| Field | Type | Description |
|---|---|---|
| request_id | string | Globally unique UUID that is returned with every API call. This value is important to log for debugging purposes; we may ask for this value to help identify a specific API call when helping you debug an issue. |
| organization | object | The Organization object. |
| status_code | integer |
The HTTP status code of the response. Stytch follows standard HTTP response status code patterns, e.g. 2XX values equate to success, 3XX values are redirects, 4XX are client errors, and 5XX are server errors. |