Organization
Organization
Organization works with the organizations of the signed-in user, in the Contentstack.Management.Core.Models namespace.
When to Use This Class: Use this class to list organizations and their stacks, to invite or remove users, or to hand the organization to a new owner.
Conceptual Role: Acts as the Content Management API (CMA) client for the /organizations requests. Call client.Organization() to get an instance.
Returns: Organization. A handle for organization requests.
Instance State
The UID you pass to client.Organization() decides which methods you can call:
- Call client.Organization() without a UID to list every organization of the user with GetOrganizations.
- Call client.Organization("<ORGANIZATION_UID>") to work with one organization, for example GetStacks or AddUser. GetOrganizations on this object fetches that one organization.
Every method except GetOrganizations throws InvalidOperationException when the object has no UID or an empty one. The Method Index below lists every method.
Note The object also has a public constructor, new Organization(client, uid), and a settable Uid property. Both work like client.Organization(uid), and the SDK reads Uid on every call.
Class-Level Notes
Authentication.
- Every method throws InvalidOperationException when the client has no authtoken. Organization requests act as a signed-in user, so a stack management token does not apply. An Open Authorization (OAuth) access token counts as an authtoken.
- Most write requests need the owner or an admin role in the organization.
Errors.
- The SDK throws ContentstackErrorException when the API rejects a request. A method that returns without throwing returns a ContentstackResponse with a success status.
Rate Limiting & Retry.
- This SDK automatically retries on 429 and on server errors, with configurable delay and attempt limits.
Additional Resource Refer to the ContentstackClientOptions class page to configure retries.
Where the API reference lists these requests.
- The downloaded CMA reference lists each organization request by name, without a section link. Each method page names the request it sends.
Class-Level Properties
| Property | Type | Access | Default | Description |
|---|---|---|---|---|
| Uid | string? | Read/write | The UID passed to client.Organization() | UID of the organization the requests target. |
Capability Matrix
| Capability | Supported | Notes / Alternative |
|---|---|---|
| Manage organization teams | No | Use the CMA team requests directly. |
| Read the organization audit log | No | Use the CMA organization log requests directly. |
| Resend an ownership transfer invitation | No | Call TransferOwnership again. |
Method Index
Find organizations. Available on client.Organization(), with or without a UID.
| Method Name | Returns | Description |
|---|---|---|
| GetOrganizations | The API response with the requested organizations. | Lists every organization, or fetches one. |
| GetOrganizationsAsync | The API response with the requested organizations. | Lists or fetches organizations asynchronously. |
Read one organization. Available on client.Organization("<ORGANIZATION_UID>").
| Method Name | Returns | Description |
|---|---|---|
| GetStacks | The API response with the organization stacks. | Lists the stacks of the organization. |
| GetStacksAsync | The API response with the organization stacks. | Lists the stacks asynchronously. |
| Roles | The API response with the roles of the organization. | Lists the roles of the organization. |
| RolesAsync | The API response with the roles of the organization. | Lists the roles asynchronously. |
Manage users. Available on client.Organization("<ORGANIZATION_UID>").
| Method Name | Returns | Description |
|---|---|---|
| AddUser | The API response with the sent invitations. | Invites users with roles in the organization and its stacks. |
| AddUserAsync | The API response with the sent invitations. | Invites users asynchronously. |
| GetInvitations | The API response with the organization invitations. | Lists the invitations. |
| GetInvitationsAsync | The API response with the organization invitations. | Lists the invitations asynchronously. |
| ResendInvitation | The API response with the resent invitation notice. | Sends a pending invitation again. |
| ResendInvitationAsync | The API response with the resent invitation notice. | Sends a pending invitation again asynchronously. |
| RemoveUser | The API response with the removal result. | Removes users by email. |
| RemoveUserAsync | The API response with the removal result. | Removes users asynchronously. |
Change the owner. Available on client.Organization("<ORGANIZATION_UID>").
| Method Name | Returns | Description |
|---|---|---|
| TransferOwnership | The API response with the ownership transfer notice. | Invites a user to become the owner. |
| TransferOwnershipAsync | The API response with the ownership transfer notice. | Invites a new owner asynchronously. |
Class-Level Snippet
This snippet prints the roles of the organization, then invites a user with one of those role UIDs.
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Models;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
Organization organization = client.Organization("<ORGANIZATION_UID>");
try
{
ContentstackResponse roles = await organization.RolesAsync();
Console.WriteLine(roles.OpenJsonObjectResponse().ToJsonString());
List<UserInvitation> invite = new List<UserInvitation>
{
new UserInvitation() { Email = "<EMAIL>", Roles = new List<string> { "<ROLE_UID>" } }
};
ContentstackResponse response = await organization.AddUserAsync(invite, null);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}Methods
Each method of the Organization class has its own section below, with its parameters, validation rules, behavior, and examples.
AddUser
AddUser invites users to an organization with roles in the organization, stack roles, or both.
| Name | Type | Description |
|---|---|---|
| orgInvite (required) | List<UserInvitation> | Users and their role UIDs in the organization. Pass null to skip. |
| stackInvite (required) | Dictionary<string, List<UserInvitation>> | Stack API key mapped to users and stack role UIDs. Pass null to skip. |
Returns: ContentstackResponse. The API response with the sent invitations.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ArgumentNullException if a UserInvitation has a null Email, and NullReferenceException if it has a null Roles list, because the SDK writes both into the request body. These surface when the SDK builds the request body, before the SDK sends anything.
- orgInvite and stackInvite can each be null. With both null, the SDK sends an empty share object.
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- AddUser sends POST /organizations/<ORGANIZATION_UID>/share, the Add users to Organization request of the Content Management API (CMA), with the body {"share": {"users": {...}, "stacks": {...}}}.
- Each orgInvite item becomes "<EMAIL>": ["<ROLE_UID>"] under users. Each stackInvite item becomes "<EMAIL>": {"<API_KEY>": ["<ROLE_UID>"]} under stacks.
- Only the owner or an admin of the organization can add users. Get the role UIDs from Roles.
- The SDK does not send the Uid of UserInvitation. See the UserInvitation class page.
Known issue When one email appears under two API keys in stackInvite, the SDK writes that email twice in the stacks object of the request body. Invite a user to one stack per call.
Example
Basic usage: invite a user with a role in the organization
using System;
using System.Collections.Generic;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
List<UserInvitation> orgInvite = new List<UserInvitation>
{
new UserInvitation() { Email = "<EMAIL>", Roles = new List<string> { "<ROLE_UID>" } }
};
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").AddUser(orgInvite, null);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: roles in the organization and in a stack
using System;
using System.Collections.Generic;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
List<UserInvitation> orgInvite = new List<UserInvitation>
{
new UserInvitation() { Email = "<EMAIL>", Roles = new List<string> { "<ROLE_UID>" } }
};
Dictionary<string, List<UserInvitation>> stackInvite = new Dictionary<string, List<UserInvitation>>
{
["<API_KEY>"] = new List<UserInvitation>
{
new UserInvitation() { Email = "<EMAIL>", Roles = new List<string> { "<STACK_ROLE_UID>" } }
}
};
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").AddUser(orgInvite, stackInvite);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}AddUserAsync
AddUserAsync invites users to an organization with roles in the organization, stack roles, or both, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| orgInvite (required) | List<UserInvitation> | Users and their role UIDs in the organization. Pass null to skip. |
| stackInvite (required) | Dictionary<string, List<UserInvitation>> | Stack API key mapped to users and stack role UIDs. Pass null to skip. |
Returns: Task<ContentstackResponse>. The API response with the sent invitations.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ArgumentNullException if a UserInvitation has a null Email, and NullReferenceException if it has a null Roles list, because the SDK writes both into the request body. These surface when the SDK builds the request body, so AddUserAsync raises them when you await the task.
- orgInvite and stackInvite can each be null. With both null, the SDK sends an empty share object.
- The SDK throws the two InvalidOperationException cases when you call AddUserAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Otherwise behaves like AddUser.
Example
Basic usage: invite a user with a role in the organization
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
List<UserInvitation> orgInvite = new List<UserInvitation>
{
new UserInvitation() { Email = "<EMAIL>", Roles = new List<string> { "<ROLE_UID>" } }
};
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").AddUserAsync(orgInvite, null);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: roles in the organization and in a stack
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Contentstack.Management.Core.Models;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
List<UserInvitation> orgInvite = new List<UserInvitation>
{
new UserInvitation() { Email = "<EMAIL>", Roles = new List<string> { "<ROLE_UID>" } }
};
Dictionary<string, List<UserInvitation>> stackInvite = new Dictionary<string, List<UserInvitation>>
{
["<API_KEY>"] = new List<UserInvitation>
{
new UserInvitation() { Email = "<EMAIL>", Roles = new List<string> { "<STACK_ROLE_UID>" } }
}
};
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").AddUserAsync(orgInvite, stackInvite);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}GetInvitations
GetInvitations retrieves the invitations of an organization.
| Name | Type | Description |
|---|---|---|
| parameter | ParameterCollection? | Query parameters, such as include_roles or include_count. |
Returns: ContentstackResponse. The API response with the organization invitations.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- GetInvitations sends GET /organizations/<ORGANIZATION_UID>/share, the Get all Organization invitations request of the Content Management API (CMA). It accepts limit, skip, asc, desc, include_count, include_roles, include_invited_by, include_user_details, and typeahead.
- Use the UID of a pending invitation with ResendInvitation.
- Returns the raw API response.
Example
Basic usage: list the invitations
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").GetInvitations();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: include roles and a count
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection parameter = new ParameterCollection();
parameter.Add("include_roles", true);
parameter.Add("include_count", true);
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").GetInvitations(parameter);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}GetInvitationsAsync
GetInvitationsAsync retrieves the invitations of an organization, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| parameter | ParameterCollection? | Query parameters, such as include_roles or include_count. |
Returns: Task<ContentstackResponse>. The API response with the organization invitations.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- The SDK throws the client-side exceptions above when you call GetInvitationsAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Otherwise behaves like GetInvitations.
Example
Basic usage: list the invitations
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").GetInvitationsAsync();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: include roles and a count
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection parameter = new ParameterCollection();
parameter.Add("include_roles", true);
parameter.Add("include_count", true);
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").GetInvitationsAsync(parameter);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}GetOrganizations
GetOrganizations retrieves every organization of the signed-in user, or one organization when the object has a UID.
| Name | Type | Description |
|---|---|---|
| parameters | ParameterCollection? | Query parameters, such as include_count or include_plan. |
Returns: ContentstackResponse. The API response with the requested organizations.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- GetOrganizations runs without an organization UID. The UID decides which request it sends.
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Without a UID, GetOrganizations sends GET /organizations, the Get all Organizations request of the Content Management API (CMA). It accepts limit, skip, asc, desc, include_count, and typeahead.
- With a UID, it sends GET /organizations/<ORGANIZATION_UID>, the Get a single Organization request, which accepts include_plan.
- Every entry of parameters goes into the query string.
- Returns the raw API response.
Example
Basic usage: list every organization of the user
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Organization().GetOrganizations();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: one organization with its plan
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection parameters = new ParameterCollection();
parameters.Add("include_plan", true);
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").GetOrganizations(parameters);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}GetOrganizationsAsync
GetOrganizationsAsync retrieves every organization of the signed-in user, or one organization when the object has a UID, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| parameters | ParameterCollection? | Query parameters, such as include_count or include_plan. |
Returns: Task<ContentstackResponse>. The API response with the requested organizations.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- GetOrganizations runs without an organization UID. The UID decides which request it sends.
- The SDK throws the client-side exceptions above when you call GetOrganizationsAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Otherwise behaves like GetOrganizations.
Example
Basic usage: list every organization of the user
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Organization().GetOrganizationsAsync();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: one organization with its plan
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection parameters = new ParameterCollection();
parameters.Add("include_plan", true);
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").GetOrganizationsAsync(parameters);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}GetStacks
GetStacks retrieves the stacks of an organization.
| Name | Type | Description |
|---|---|---|
| parameter | ParameterCollection? | Query parameters, such as limit or include_count. |
Returns: ContentstackResponse. The API response with the organization stacks.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- GetStacks sends GET /organizations/<ORGANIZATION_UID>/stacks, the Get all stacks in an Organization request of the Content Management API (CMA). It accepts limit, skip, asc, desc, include_count, and typeahead.
- Returns the raw API response.
Example
Basic usage: list the stacks
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").GetStacks();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: one page with a count
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection parameter = new ParameterCollection();
parameter.Add("limit", 10);
parameter.Add("include_count", true);
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").GetStacks(parameter);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}GetStacksAsync
GetStacksAsync retrieves the stacks of an organization, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| parameter | ParameterCollection? | Query parameters, such as limit or include_count. |
Returns: Task<ContentstackResponse>. The API response with the organization stacks.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- The SDK throws the client-side exceptions above when you call GetStacksAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Otherwise behaves like GetStacks.
Example
Basic usage: list the stacks
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").GetStacksAsync();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: one page with a count
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection parameter = new ParameterCollection();
parameter.Add("limit", 10);
parameter.Add("include_count", true);
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").GetStacksAsync(parameter);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}RemoveUser
RemoveUser removes users from an organization by email.
| Name | Type | Description |
|---|---|---|
| emails (required) | List<string> | Emails of the users to remove. |
Returns: ContentstackResponse. The API response with the removal result.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ArgumentNullException (parameter emails) if emails is null.
- An empty list raises no SDK error. The SDK then sends the request without a body.
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Warning Removing a user takes away their access to the organization and to every stack in it. They need a new invitation to return.
Behavior
- RemoveUser sends DELETE /organizations/<ORGANIZATION_UID>/share, the Remove users from organization request of the Content Management API (CMA), with the body {"emails": [...]}.
- Only the owner or an admin of the organization can remove users.
- Returns the raw API response.
Example
Basic usage: remove one user
using System;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").RemoveUser(new List<string> { "<EMAIL>" });
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}RemoveUserAsync
RemoveUserAsync removes users from an organization by email, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| emails (required) | List<string> | Emails of the users to remove. |
Returns: Task<ContentstackResponse>. The API response with the removal result.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ArgumentNullException (parameter emails) if emails is null.
- An empty list raises no SDK error. The SDK then sends the request without a body.
- The SDK throws the client-side exceptions above when you call RemoveUserAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Warning Removing a user takes away their access to the organization and to every stack in it. They need a new invitation to return.
Behavior
- Otherwise behaves like RemoveUser.
Example
Basic usage: remove one user
using System;
using System.Threading.Tasks;
using System.Collections.Generic;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").RemoveUserAsync(new List<string> { "<EMAIL>" });
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}ResendInvitation
ResendInvitation sends a pending organization invitation again.
| Name | Type | Description |
|---|---|---|
| shareUid (required) | string | UID of the pending invitation. |
Returns: ContentstackResponse. The API response with the resent invitation notice.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ArgumentNullException (parameter shareUid) if shareUid is null or empty.
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- ResendInvitation sends GET /organizations/<ORGANIZATION_UID>/share/<SHARE_UID>/resend_invitation, the Resend pending Organization invitation request of the Content Management API (CMA).
- Get the share UID and the status of each invitation from GetInvitations.
- Only the owner or an admin of the organization can resend an invitation.
Example
Basic usage: resend one invitation
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").ResendInvitation("<SHARE_UID>");
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}ResendInvitationAsync
ResendInvitationAsync sends a pending organization invitation again, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| shareUid (required) | string | UID of the pending invitation. |
Returns: Task<ContentstackResponse>. The API response with the resent invitation notice.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ArgumentNullException (parameter shareUid) if shareUid is null or empty.
- The SDK throws the client-side exceptions above when you call ResendInvitationAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Otherwise behaves like ResendInvitation.
Example
Basic usage: resend one invitation
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").ResendInvitationAsync("<SHARE_UID>");
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}Roles
Roles retrieves the roles of an organization, which you need to invite users.
| Name | Type | Description |
|---|---|---|
| parameters | ParameterCollection? | Query parameters, such as include_stack_roles. |
Returns: ContentstackResponse. The API response with the roles of the organization.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Roles sends GET /organizations/<ORGANIZATION_UID>/roles, the Get all roles in an Organization request of the Content Management API (CMA). It accepts limit, skip, asc, desc, include_count, and include_stack_roles.
- Use the role UIDs from the response in the Roles list of each UserInvitation you pass to AddUser.
- Returns the raw API response.
Example
Basic usage: list the roles of the organization
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").Roles();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: include the stack roles
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection parameters = new ParameterCollection();
parameters.Add("include_stack_roles", true);
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").Roles(parameters);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}RolesAsync
RolesAsync retrieves the roles of an organization, which you need to invite users, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| parameters | ParameterCollection? | Query parameters, such as include_stack_roles. |
Returns: Task<ContentstackResponse>. The API response with the roles of the organization.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- The SDK throws the client-side exceptions above when you call RolesAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Behavior
- Otherwise behaves like Roles.
Example
Basic usage: list the roles of the organization
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").RolesAsync();
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}All parameters: include the stack roles
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
using Contentstack.Management.Core.Queryable;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
ParameterCollection parameters = new ParameterCollection();
parameters.Add("include_stack_roles", true);
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").RolesAsync(parameters);
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
Console.WriteLine(e.ErrorMessage);
}TransferOwnership
TransferOwnership invites another user to take over the ownership of an organization.
| Name | Type | Description |
|---|---|---|
| email (required) | string | Email of the user to become the owner. |
Returns: ContentstackResponse. The API response with the ownership transfer notice.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ArgumentNullException (parameter email) if email is null or empty.
- Throws ContentstackErrorException when the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Warning When the new owner accepts, you lose the owner role of the organization and cannot take it back yourself.
Behavior
- TransferOwnership sends POST /organizations/<ORGANIZATION_UID>/transfer-ownership, the Transfer Organization ownership request of the Content Management API (CMA), with the body {"transfer_to": ...}.
- The API emails an invitation to the user. Ownership moves only when the user accepts it.
- Returns the raw API response.
Example
Basic usage: invite a new owner
using System;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = client.Organization("<ORGANIZATION_UID>").TransferOwnership("<EMAIL>");
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}TransferOwnershipAsync
TransferOwnershipAsync invites another user to take over the ownership of an organization, without blocking the calling thread.
| Name | Type | Description |
|---|---|---|
| email (required) | string | Email of the user to become the owner. |
Returns: Task<ContentstackResponse>. The API response with the ownership transfer notice.
Validation
- Throws InvalidOperationException if the client has no authtoken, because organization requests act as a signed-in user. A stack management token does not apply.
- Throws InvalidOperationException if the organization object has no UID, because the request targets one organization. Call client.Organization("<ORGANIZATION_UID>").
- Throws ArgumentNullException (parameter email) if email is null or empty.
- The SDK throws the client-side exceptions above when you call TransferOwnershipAsync, before it returns a task.
- Throws ContentstackErrorException when you await the task and the API rejects the request.
Additional Resource Refer to Content Management API Errors for the full error code list.
Warning When the new owner accepts, you lose the owner role of the organization and cannot take it back yourself.
Behavior
- Otherwise behaves like TransferOwnership.
Example
Basic usage: invite a new owner
using System;
using System.Threading.Tasks;
using Contentstack.Management.Core;
using Contentstack.Management.Core.Exceptions;
ContentstackClient client = new ContentstackClient("<AUTHTOKEN>");
try
{
ContentstackResponse response = await client.Organization("<ORGANIZATION_UID>").TransferOwnershipAsync("<EMAIL>");
Console.WriteLine(response.OpenJsonObjectResponse().ToJsonString());
}
catch (ContentstackErrorException e)
{
// Thrown when the API rejects the request
Console.WriteLine($"Request failed: {(int)e.StatusCode} {e.ErrorCode} {e.ErrorMessage}");
}