Assign GitLab Duo seats by using GraphQL
- Tier: Premium, Ultimate
 - Offering: GitLab.com, GitLab Self-Managed, GitLab Dedicated
 
Version history
- Introduced in GitLab 16.11.
 
Use the GraphQL API to assign GitLab Duo seats to users.
Prerequisites
- You must have the Owner role for the group you want to assign seats to.
 - You must have a personal access token with the 
apiscope. 
Get the add-on purchase ID
To start, retrieve the purchase ID for the GitLab Duo add-on. For GitLab.com:
query {
 addOnPurchases (namespaceId: "gid://gitlab/Group/YOUR_NAMESPACE_ID")
 {
  name
  purchasedQuantity
  assignedQuantity
  id
 }
}
For GitLab Self-Managed and GitLab Dedicated:
query {
 addOnPurchases
 {
  name
  purchasedQuantity
  assignedQuantity
  id
 }
}
Assign a GitLab Duo seat to specific users
Then assign seats to specific users:
mutation {
  userAddOnAssignmentBulkCreate(input: {
    addOnPurchaseId: "gid://gitlab/GitlabSubscriptions::AddOnPurchase/YOUR_ADDON_PURCHASE_ID",
    userIds: [
      "gid://gitlab/User/USER_ID_1",
      "gid://gitlab/User/USER_ID_2",
      "gid://gitlab/User/USER_ID_3"
    ]
  }) {
    addOnPurchase {
      id
      name
      assignedQuantity
      purchasedQuantity
    }
    users {
      nodes {
        id
        username
        }
      }
    errors
  }
}
Use GraphQL
You can use GraphQL to assign seats to users.
- Copy the add-on purchase ID code excerpt.
 - Open GraphQL.
 - In the left window, enter the query for getting an add-on purchase ID.
 - Select Play.
 - Repeat to assign a GitLab Duo seat to specific users.