(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
- ListForInstance - Get a list of all organization memberships within an instance.
Adds a user as a member to the given organization.
using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;
var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.OrganizationMemberships.CreateAsync(
organizationId: "org_123",
requestBody: new CreateOrganizationMembershipRequestBody() {
UserId = "user_456",
Role = "admin",
}
);
// handle response
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
OrganizationId |
string | ✔️ | The ID of the organization where the new membership will be created | org_123 |
RequestBody |
CreateOrganizationMembershipRequestBody | ✔️ | N/A |
CreateOrganizationMembershipResponse
Error Type | Status Code | Content Type |
---|---|---|
Clerk.BackendAPI.Models.Errors.ClerkErrors | 400, 403, 404, 422 | application/json |
Clerk.BackendAPI.Models.Errors.SDKError | 4XX, 5XX | */* |
Retrieves all user memberships for the given organization
using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;
var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.OrganizationMemberships.ListAsync(
organizationId: "org_789",
limit: 20,
offset: 10,
orderBy: "+created_at"
);
// handle response
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
OrganizationId |
string | ✔️ | The organization ID. | org_789 |
Limit |
long | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset . |
20 |
Offset |
long | ➖ | Skip the first offset results when paginating.Needs to be an integer greater or equal to zero. To be used in conjunction with limit . |
10 |
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." |
+created_at |
ListOrganizationMembershipsResponse
Error Type | Status Code | Content Type |
---|---|---|
Clerk.BackendAPI.Models.Errors.ClerkErrors | 401, 422 | application/json |
Clerk.BackendAPI.Models.Errors.SDKError | 4XX, 5XX | */* |
Updates the properties of an existing organization membership
using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;
var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.OrganizationMemberships.UpdateAsync(
organizationId: "org_12345",
userId: "user_67890",
requestBody: new UpdateOrganizationMembershipRequestBody() {
Role = "admin",
}
);
// handle response
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
OrganizationId |
string | ✔️ | The ID of the organization the membership belongs to | org_12345 |
UserId |
string | ✔️ | The ID of the user that this membership belongs to | user_67890 |
RequestBody |
UpdateOrganizationMembershipRequestBody | ✔️ | N/A |
UpdateOrganizationMembershipResponse
Error Type | Status Code | Content Type |
---|---|---|
Clerk.BackendAPI.Models.Errors.ClerkErrors | 400, 404, 422 | application/json |
Clerk.BackendAPI.Models.Errors.SDKError | 4XX, 5XX | */* |
Removes the given membership from the organization
using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;
var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.OrganizationMemberships.DeleteAsync(
organizationId: "org_12345",
userId: "user_67890"
);
// handle response
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
OrganizationId |
string | ✔️ | The ID of the organization the membership belongs to | org_12345 |
UserId |
string | ✔️ | The ID of the user that this membership belongs to | user_67890 |
DeleteOrganizationMembershipResponse
Error Type | Status Code | Content Type |
---|---|---|
Clerk.BackendAPI.Models.Errors.ClerkErrors | 400, 401, 404 | application/json |
Clerk.BackendAPI.Models.Errors.SDKError | 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
.
using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using System.Collections.Generic;
using Clerk.BackendAPI.Models.Components;
var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.OrganizationMemberships.UpdateMetadataAsync(
organizationId: "org_123456",
userId: "user_654321",
requestBody: new UpdateOrganizationMembershipMetadataRequestBody() {
PublicMetadata = new Dictionary<string, object>() {
},
PrivateMetadata = new Dictionary<string, object>() {
},
}
);
// handle response
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
OrganizationId |
string | ✔️ | The ID of the organization the membership belongs to | org_123456 |
UserId |
string | ✔️ | The ID of the user that this membership belongs to | user_654321 |
RequestBody |
UpdateOrganizationMembershipMetadataRequestBody | ✔️ | N/A |
UpdateOrganizationMembershipMetadataResponse
Error Type | Status Code | Content Type |
---|---|---|
Clerk.BackendAPI.Models.Errors.ClerkErrors | 400, 404, 422 | application/json |
Clerk.BackendAPI.Models.Errors.SDKError | 4XX, 5XX | */* |
Retrieves all organization user memberships for the given instance.
using Clerk.BackendAPI;
using Clerk.BackendAPI.Models.Operations;
using Clerk.BackendAPI.Models.Components;
var sdk = new ClerkBackendApi(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.OrganizationMemberships.ListForInstanceAsync(
limit: 20,
offset: 10,
orderBy: "<value>"
);
// handle response
Parameter | Type | Required | Description | Example |
---|---|---|---|---|
Limit |
long | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset . |
20 |
Offset |
long | ➖ | Skip the first offset results when paginating.Needs to be an integer greater or equal to zero. To be used in conjunction with limit . |
10 |
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. |
InstanceGetOrganizationMembershipsResponse
Error Type | Status Code | Content Type |
---|---|---|
Clerk.BackendAPI.Models.Errors.ClerkErrors | 400, 401, 422, 500 | application/json |
Clerk.BackendAPI.Models.Errors.SDKError | 4XX, 5XX | */* |