The Create External Connection method wraps the Create External Connection API endpoint. The organization_id will be automatically inferred from the logged-in Member's session. This method cannot be used to create External connections in other Organizations.
Create External Connection
Method parameters
A human-readable display name for the connection.
Globally unique UUID that identifies a different Organization within your Project.
Globally unique UUID that identifies a specific SSO connection configured for a different Organization in your Project.
Response fields
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.
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.
The External Connection object affected by this API call. See the External Connection Object for complete response field details.
import { useStytchB2BClient } from '@stytch/react-native/b2b';
import React from 'react';
import { Text, TouchableOpacity, View } from 'react-native';
export const CreateExternalConnection = () => {
const stytch = useStytchB2BClient();
const createExternalConnection = () => {
stytch.sso.external.createConnection({
display_name: 'Example External connection',
external_organization_id: 'organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931',
external_connection_id: 'saml-connection-test-51861cbc-d3b9-428b-9761-227f5fb12be9',
});
};
return (
<View>
<TouchableOpacity onPress={createExternalConnection}>
<Text>Create an External Connection</Text>
</TouchableOpacity>
</View>
);
};
{
"connection": {
"connection_id": "external-connection-test-5c44cc6a-8af7-48d6-8da7-ea821342f5a6",
"display_name": "Example External Connection",
"organization_id": "organization-test-07971b06-ac8b-4cdb-9c15-63b17e653931",
"external_organization_id": "organization-test-ca6dbe77-10e5-4403-805a-b117c55c24c6",
"external_connection_id": "saml-connection-test-51861cbc-d3b9-428b-9761-227f5fb12be9",
"status": "active",
},
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"status_code": 200
}
{
"status_code": 401,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "unauthorized_credentials",
"error_message": "Unauthorized credentials.",
"error_url": "https://stytch.com/docs/api/errors/401"
}
{
"status_code": 403,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "session_authorization_error",
"error_message": "The Member is not authorized to perform the requested action on that resource.",
"error_url": "https://stytch.com/docs/api/errors/403"
}
{
"status_code": 429,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "too_many_requests",
"error_message": "Too many requests have been made.",
"error_url": "https://stytch.com/docs/api/errors/429"
}
{
"status_code": 500,
"request_id": "request-id-test-b05c992f-ebdc-489d-a754-c7e70ba13141",
"error_type": "internal_server_error",
"error_message": "Oops, something seems to have gone wrong, please reach out to support@stytch.com to let us know what went wrong.",
"error_url": "https://stytch.com/docs/api/errors/500"
}