File: assign_gitlab_duo_seats.md

package info (click to toggle)
gitlab 17.6.5-19
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 629,368 kB
  • sloc: ruby: 1,915,304; javascript: 557,307; sql: 60,639; xml: 6,509; sh: 4,567; makefile: 1,239; python: 406
file content (93 lines) | stat: -rw-r--r-- 1,986 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
---
stage: Fulfillment
group: Provision
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://handbook.gitlab.com/handbook/product/ux/technical-writing/#assignments
---

# Assign GitLab Duo seats by using GraphQL

DETAILS:
**Tier:** Premium, Ultimate
**Offering:** GitLab.com

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 `api` scope.

## Get the add-on purchase ID

To start, retrieve the purchase ID for the GitLab Duo add-on:

```graphql
query {
 addOnPurchases (namespaceId: "gid://gitlab/Group/YOUR_NAMESPACE_ID")
 {
  name
  purchasedQuantity
  assignedQuantity
  id
 }
}
```

## Assign a GitLab Duo seat to specific users

Then assign seats to specific users:

```graphql
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 GraphiQL

You can use [GraphiQL](https://gitlab.com/-/graphql-explorer) to assign seats to users.

1. Copy the add-on purchase ID code excerpt.
1. Open GraphiQL.
1. In the left window, enter the query:

   ```graphql
   query {
    addOnPurchases (namespaceId: "gid://gitlab/Group/YOUR_NAMESPACE_ID")
    {
     name
     purchasedQuantity
     assignedQuantity
     id
    }
   }
   ```

1. Select **Play**.
1. Repeat to assign a GitLab Duo seat to specific users.

## Related topics

- [GraphQL API Resources](reference/index.md)
- [GraphQL specific entities, like fragments and interfaces](https://graphql.org/learn/)