(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
Adds a user as a member to the given organization. Only users in the same instance as the organization can be added as members.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
CreateOrganizationMembershipResponse res = sdk.organizationMemberships().create()
.organizationId("<value>")
.requestBody(CreateOrganizationMembershipRequestBody.builder()
.userId("<value>")
.role("<value>")
.build())
.call();
if (res.organizationMembership().isPresent()) {
// handle response
}
} catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
// handle exception
throw e;
} catch (com.clerk.backend_api.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
organizationId |
String | ✔️ | The ID of the organization where the new membership will be created |
requestBody |
com.clerk.backend_api.models.operations.CreateOrganizationMembershipRequestBody | ✔️ | N/A |
Optional<? extends com.clerk.backend_api.models.operations.CreateOrganizationMembershipResponse>
Error Object | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 400,403,404,422 | application/json |
models/errors/SDKError | 4xx-5xx | / |
Retrieves all user memberships for the given organization
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
ListOrganizationMembershipsResponse res = sdk.organizationMemberships().list()
.organizationId("<value>")
.limit(10L)
.offset(0L)
.orderBy("<value>")
.call();
while (true) {
if (res.organizationMemberships().isPresent()) {
// handle response
Optional<ListOrganizationMembershipsResponse> nextRes = res.next();
if (nextRes.isPresent()) {
res = nextRes.get();
} else {
break;
}
}
}
} catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
// handle exception
throw e;
} catch (com.clerk.backend_api.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
Parameter | Type | Required | Description |
---|---|---|---|
organizationId |
String | ✔️ | The organization ID. |
limit |
Optional<? extends Long> | ➖ | Applies a limit to the number of results returned. Can be used for paginating the results together with offset . |
offset |
Optional<? extends 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 . |
orderBy |
Optional<? extends 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." |
Optional<? extends com.clerk.backend_api.models.operations.ListOrganizationMembershipsResponse>
Error Object | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 401,422 | application/json |
models/errors/SDKError | 4xx-5xx | / |
Updates the properties of an existing organization membership
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
UpdateOrganizationMembershipResponse res = sdk.organizationMemberships().update()
.organizationId("<value>")
.userId("<value>")
.requestBody(UpdateOrganizationMembershipRequestBody.builder()
.role("<value>")
.build())
.call();
if (res.organizationMembership().isPresent()) {
// handle response
}
} catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
// handle exception
throw e;
} catch (com.clerk.backend_api.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
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 |
com.clerk.backend_api.models.operations.UpdateOrganizationMembershipRequestBody | ✔️ | N/A |
Optional<? extends com.clerk.backend_api.models.operations.UpdateOrganizationMembershipResponse>
Error Object | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 400,404,422 | application/json |
models/errors/SDKError | 4xx-5xx | / |
Removes the given membership from the organization
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
DeleteOrganizationMembershipResponse res = sdk.organizationMemberships().delete()
.organizationId("<value>")
.userId("<value>")
.call();
if (res.organizationMembership().isPresent()) {
// handle response
}
} catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
// handle exception
throw e;
} catch (com.clerk.backend_api.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
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 |
Optional<? extends com.clerk.backend_api.models.operations.DeleteOrganizationMembershipResponse>
Error Object | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 400,401,404 | application/json |
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
.
package hello.world;
import com.clerk.backend_api.Clerk;
import com.clerk.backend_api.models.components.*;
import com.clerk.backend_api.models.components.Security;
import com.clerk.backend_api.models.operations.*;
import com.clerk.backend_api.utils.EventStream;
import java.math.BigDecimal;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Optional;
import org.openapitools.jackson.nullable.JsonNullable;
import static java.util.Map.entry;
public class Application {
public static void main(String[] args) throws Exception {
try {
Clerk sdk = Clerk.builder()
.bearerAuth("<YOUR_BEARER_TOKEN_HERE>")
.build();
UpdateOrganizationMembershipMetadataResponse res = sdk.organizationMemberships().updateMetadata()
.organizationId("<value>")
.userId("<value>")
.requestBody(UpdateOrganizationMembershipMetadataRequestBody.builder()
.build())
.call();
if (res.organizationMembership().isPresent()) {
// handle response
}
} catch (com.clerk.backend_api.models.errors.ClerkErrors e) {
// handle exception
throw e;
} catch (com.clerk.backend_api.models.errors.SDKError e) {
// handle exception
throw e;
} catch (Exception e) {
// handle exception
throw e;
}
}
}
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 |
com.clerk.backend_api.models.operations.UpdateOrganizationMembershipMetadataRequestBody | ✔️ | N/A |
Error Object | Status Code | Content Type |
---|---|---|
models/errors/ClerkErrors | 400,404,422 | application/json |
models/errors/SDKError | 4xx-5xx | / |