(organizationMemberships)
- create - Create a new organization membership
- list - Get a list of all members of an organization
- update - Update an organization membership
- delete - Remove a member from an organization
- updateMetadata - Merge and update organization membership metadata
- getAll - Get a list of all organization memberships within an instance.
Adds a user as a member to the given organization. Only users in the same instance as the organization can be added as members.
This organization will be the user's [active organization] (https://clerk.com/docs/organizations/overview#active-organization) the next time they create a session, presuming they don't explicitly set a different organization as active before then.
declare(strict_types=1);
require 'vendor/autoload.php';
use Clerk\Backend;
use Clerk\Backend\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Backend\ClerkBackend::builder()->setSecurity($security)->build();
$requestBody = new Operations\CreateOrganizationMembershipRequestBody(
userId: '<id>',
role: '<value>',
);
$response = $sdk->organizationMemberships->create(
organizationId: '<id>',
requestBody: $requestBody
);
if ($response->organizationMembership !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
organizationId |
string | ✔️ | The ID of the organization where the new membership will be created |
requestBody |
Operations\CreateOrganizationMembershipRequestBody | ✔️ | N/A |
?Operations\CreateOrganizationMembershipResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ClerkErrors79 | 400, 403, 404, 422 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
Retrieves all user memberships for the given organization
declare(strict_types=1);
require 'vendor/autoload.php';
use Clerk\Backend;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Backend\ClerkBackend::builder()->setSecurity($security)->build();
$response = $sdk->organizationMemberships->list(
organizationId: '<id>',
limit: 10,
offset: 0,
orderBy: '<value>'
);
if ($response->organizationMemberships !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
organizationId |
string | ✔️ | The organization ID. |
limit |
?int | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset . |
offset |
?int | ➖ | Skip the first offset results when paginating.Needs to be an integer greater or equal to zero. To be used in conjunction with limit . |
orderBy |
?string | ➖ | Sorts organizations memberships by phone_number, email_address, created_at, first_name, last_name or username. By prepending one of those values with + or -, we can choose to sort in ascending (ASC) or descending (DESC) order." |
?Operations\ListOrganizationMembershipsResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ClerkErrors80 | 401, 422 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
Updates the properties of an existing organization membership
declare(strict_types=1);
require 'vendor/autoload.php';
use Clerk\Backend;
use Clerk\Backend\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Backend\ClerkBackend::builder()->setSecurity($security)->build();
$requestBody = new Operations\UpdateOrganizationMembershipRequestBody(
role: '<value>',
);
$response = $sdk->organizationMemberships->update(
organizationId: '<id>',
userId: '<id>',
requestBody: $requestBody
);
if ($response->organizationMembership !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
organizationId |
string | ✔️ | The ID of the organization the membership belongs to |
userId |
string | ✔️ | The ID of the user that this membership belongs to |
requestBody |
Operations\UpdateOrganizationMembershipRequestBody | ✔️ | N/A |
?Operations\UpdateOrganizationMembershipResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ClerkErrors81 | 400, 404, 422 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
Removes the given membership from the organization
declare(strict_types=1);
require 'vendor/autoload.php';
use Clerk\Backend;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Backend\ClerkBackend::builder()->setSecurity($security)->build();
$response = $sdk->organizationMemberships->delete(
organizationId: '<id>',
userId: '<id>'
);
if ($response->organizationMembership !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
organizationId |
string | ✔️ | The ID of the organization the membership belongs to |
userId |
string | ✔️ | The ID of the user that this membership belongs to |
?Operations\DeleteOrganizationMembershipResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ClerkErrors82 | 400, 401, 404 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
Update an organization membership's metadata attributes by merging existing values with the provided parameters.
Metadata values will be updated via a deep merge. Deep means that any nested JSON objects will be merged as well.
You can remove metadata keys at any level by setting their value to null
.
declare(strict_types=1);
require 'vendor/autoload.php';
use Clerk\Backend;
use Clerk\Backend\Models\Operations;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Backend\ClerkBackend::builder()->setSecurity($security)->build();
$requestBody = new Operations\UpdateOrganizationMembershipMetadataRequestBody();
$response = $sdk->organizationMemberships->updateMetadata(
organizationId: '<id>',
userId: '<id>',
requestBody: $requestBody
);
if ($response->organizationMembership !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
organizationId |
string | ✔️ | The ID of the organization the membership belongs to |
userId |
string | ✔️ | The ID of the user that this membership belongs to |
requestBody |
Operations\UpdateOrganizationMembershipMetadataRequestBody | ✔️ | N/A |
?Operations\UpdateOrganizationMembershipMetadataResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ClerkErrors83 | 400, 404, 422 | application/json |
Errors\SDKException | 4XX, 5XX | */* |
Retrieves all organization user memberships for the given instance.
declare(strict_types=1);
require 'vendor/autoload.php';
use Clerk\Backend;
$security = '<YOUR_BEARER_TOKEN_HERE>';
$sdk = Backend\ClerkBackend::builder()->setSecurity($security)->build();
$response = $sdk->organizationMemberships->getAll(
limit: 10,
offset: 0,
orderBy: '<value>'
);
if ($response->organizationMemberships !== null) {
// handle response
}
Parameter | Type | Required | Description |
---|---|---|---|
limit |
?int | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset . |
offset |
?int | ➖ | Skip the first offset results when paginating.Needs to be an integer greater or equal to zero. To be used in conjunction with limit . |
orderBy |
?string | ➖ | Sorts organizations memberships by phone_number, email_address, created_at, first_name, last_name or username. By prepending one of those values with + or -, we can choose to sort in ascending (ASC) or descending (DESC) order. |
?Operations\InstanceGetOrganizationMembershipsResponse
Error Type | Status Code | Content Type |
---|---|---|
Errors\ClerkErrors104 | 400, 401, 422, 500 | application/json |
Errors\SDKException | 4XX, 5XX | */* |