Organizations (GQL)
Create an organization
Creates an organization owned by the logged in user. That user is automatically an org admin for the organization. The input.email
field is used to specify the email address that invoices and notifications will be sent to. This value is shown in the Organization Dashboard in the Organization Settings tab.
The thumbnail
field can contain a full URL or a reference to a file on the local computer (for example, "/static-assets/default/teamContext.svg").
The input.users
field is used to invite users to the organization. It should contain an array of one or more objects. The user can be specified by email address or by Rapid user id. The name of the invited user's role can also be specified. If you would like to automatically add instead of invite users to the organization, you could alternatively use the REST Platform API's Add Team User(s)
endpoint.
Note that creating an organization will automatically create a default team, a default app for that team, and a special type of subscription of type SEATS for the organization. You can view these creation events using the Events tab.
mutation CreateOrganization ($input: OrganizationCreateInput!) {
createOrganization(input:$input) {
name,
id
}
}
{
"input": {
"name": "Org X",
"email": "[email protected]",
"seats": 7,
"thumbnail": "https://rapidapi.com/cdn/images?url=https://rapidapi-prod-apis.s3.amazonaws.com/abab68f8-9131-40db-861c-3b971503e4c2.png",
"users": [
{
"email": "[email protected]",
"role": "ADMIN"
},
{
"id": "5753721",
"role": "DEVELOPER"
}
]
}
}
Obtain an organization's details by ID
Lists an organization's details given its organization ID. The calling user must be a member of the organization.
query.organizations
There is also a
query.organizations
query shown below.
query Organization ($id: ID!) {
organization(id: $id) {
id
name
slugifiedName
teams {
id
name
ProjectAcls {
Project {
id
name
description
thumbnail
mashapeId
enableLimitsToAPIs
projectAllowedAPIs {
id
}
}
}
}
users {
name
email
id
}
}
}
{
"id": ORG_ID
}
In the response, the ProjectAcls section contains App information (id and name). Apps are called "Projects" in the Platform API. Apps are shown in the Developer Dashboard (Apps).
Obtain an organization's details by ID (Admin)
Admin query
This query requires that the user is an Environment Admin. This is similar to the query used in the Admin Panel when viewing an Organization's details.
Lists an organization's details given its organization ID.
query getOrg(
$id: ID!
$whereRoles: RoleWhereInput!
$papiWhere: RoleWhereInput!
$whereOrgTeam: WhereOrgTeam
$defaultRoleWhere: RoleWhereInput!
) {
organization(id: $id, where: $whereOrgTeam) {
...OrgDetailsFields
__typename
}
roles(where: $whereRoles) {
nodes {
...OrgRolesFields
__typename
}
__typename
}
papiRoles: roles(where: $papiWhere) {
nodes {
...PapiRoleFields
__typename
}
__typename
}
defaultRole: roles(where: $defaultRoleWhere) {
nodes {
...OrgRolesFields
__typename
}
__typename
}
}
fragment OrgDetailsFields on Organization {
id
slugifiedName
name
status
entity
createdAt
updatedAt
apisCount
role {
id
entityId
roleId
role {
name
__typename
}
__typename
}
apis {
...OrgApiFields
__typename
}
externalSubscriptions {
...OrgSubsFields
__typename
}
internalSubscriptions {
...OrgSubsFields
__typename
}
ProjectAcls {
...OrgProjectFields
__typename
}
users(roleInOrgCtx: true) {
...OrgUserFields
__typename
}
teams(where: $whereOrgTeam) {
...OrgTeamFields
__typename
}
__typename
}
fragment OrgRolesFields on Role {
id
name
description
isBasicRole
isDefault
__typename
}
fragment PapiRoleFields on Role {
id
name
description
isDefault
permissions {
id
key
displayName
permissionLevel
description
dependsOn
rolePermission {
granted
readOnly
__typename
}
__typename
}
__typename
}
fragment OrgApiFields on Api {
id
name
owner {
name
id
__typename
}
createdAt
category
pricing
status
visibility
__typename
}
fragment OrgSubsFields on BillingSubscription {
id
api {
id
name
__typename
}
status
createdAt
updatedAt
deletedAt
entity {
id
name
__typename
}
__typename
}
fragment OrgProjectFields on AdminProjectAcl {
id
createdAt
owner {
id
name
__typename
}
Project {
id
name
applicationAuthorizations {
id
key
__typename
}
__typename
}
__typename
}
fragment OrgUserFields on User {
id
name
email
username
role {
role {
name
__typename
}
__typename
}
Teams {
id
__typename
}
__typename
}
fragment OrgTeamFields on Team {
id
name
usersCount
createdAt
role(where: $whereOrgTeam) {
id
roleId
__typename
}
__typename
}
{
"id": "5755578",
"whereRoles": {
"roleLevels": [
"ORGANIZATION"
]
},
"papiWhere": {
"roleLevels": [
"TEAM_ENVIRONMENT"
]
},
"whereOrgTeam": {
"orgId": "5755578",
"parentId": "5755578"
},
"defaultRoleWhere": {
"roleLevels": [
"USER_ORGANIZATION"
]
}
}
Obtain all organizations' details (Admin)
Admin query
This query requires the user to be an Environment Admin.
TBD
Obtain one or more organization's details
Alternative query
The query below assumes the calling user is an org admin. To obtain the list of organizations that any user belongs to, use
query.users
. See Users, Teams, and Roles (GQL)
Alternative query
If you are interested in obtaining a single organization's detail by its ID, see the
query.organization
query above.
Lists one or more organization's details, including teams and users. The x-rapidapi-identity-key
must be the Personal Account key of an org admin in the organization, and this query must be executed from a team context. See Authorization (GQL). Only organizations in which the Personal Account key is an org admin will be returned.
Variables can be set with userID
, which lists all organizations for which the calling user is a member, or with slugifiedName
, which lists a single organization's details. If you do not set either variable, the result lists all organizations for which the calling user is an org admin.
In the response, the ProjectAcls section contains App information (id and name). Apps are called "Projects" in the Platform API. Apps are shown in the Developer Dashboard (Apps).
query Organizations($where: OrganizationWhereInput!) {
organizations(where: $where) {
name
slugifiedName
id
teams {
id
name
ProjectAcls {
Project {
id
name
}
}
}
users {
name
email
id
}
}
}
{
"where": {
"userId": YOUR_USER_ID
}
}
{
"where": {
"slugifiedName": "platform-management"
}
}
Update an organization
Use the input.seats
to update the org's number of seats. The thumbnail
field can contain a full URL or a reference to a file on the local computer (for example, "/static-assets/default/teamContext.svg").
mutation UpdateOrganization($input: OrganizationUpdateInput!) {
updateOrganization (input: $input){
billingAdditionalValues {
total
}
}
}
{
"input": {
"organizationId": ORG_ID,
"seats": 35,
""thumbnail": "https://rapidapi.com/cdn/images?url=https://rapidapi-prod-apis.s3.amazonaws.com/abab68f8-9131-40db-861c-3b971503e4c2.png"
}
}
Delete an organization
mutation DeleteOrganization {
deleteOrganization(id: int)
}
Updated 9 months ago