Your profile

One profile for every MSDEVBUILD site. Only you can see it, and the site owner if you write in.

Lesson 15 of 30
❮Prev Next❯

Audit Log Events and Managing Seats with the REST API

Module 2: Copilot Features ⏱ 10 min read Updated

Your note

My notes for this lesson

Select any text in the lesson to highlight it or add a note. Saved in this browser.

    No highlights yet. Select a sentence in the lesson, then pick a colour or add a note.

    All my bookmarks and notes

    Reading settings

    For every lesson, saved in this browser.

    Text size
    Line spacing
    Font

    With IaaS you rent the virtual machine. Microsoft looks after the building, power and hardware; you patch the operating system.

    30-second answer

    Every Copilot admin change leaves a trail in the organization's audit log: events start with copilot. (seats added or cancelled, policy changes, content exclusion changes) and you find them by searching action:copilot. To manage the subscription in code, use the Copilot user management REST API: GET /orgs/{org}/copilot/billing for the settings, GET /orgs/{org}/copilot/billing/seats for every seat with last_activity_at and last_activity_editor, and POST or DELETE /orgs/{org}/copilot/billing/selected_users (or /selected_teams) to add or cancel seats. The token needs the manage_billing:copilot scope, and a cancelled seat stays active until the end of the billing cycle.

    Simulate it » No Azure account needed

    Exam objective: 2.4.2 Use audit log events. 2.4.3 Manage subscriptions using the REST API. (Skills measured as of August 7, 2026)

    Simulations

    Feel it before you read it. No account needed, nothing leaves this page.

    VS Code & GitHub: Seats with the REST API, and the audit log Search the audit log, then manage seats with the REST API.
    </> Embed

    Embed this simulation

    Free for trainers, teachers and bloggers. Paste this into your page:

    Loading…

    The <strong>audit log</strong> (organization settings › Archive › Logs) records Copilot events: seats added or cancelled, policy changes, content exclusion changes. Filter with <code>action:copilot</code>; the event names here are examples, so check the docs for the exact list.

    👆 Click the glowing item on screen to continue

    Read the steps as text
    1. The audit log (organization settings › Archive › Logs) records Copilot events: seats added or cancelled, policy changes, content exclusion changes. Filter with action:copilot; the event names here are examples, so check the docs for the exact list.
    2. The Copilot user management REST API lists seats with last_activity_at, so you can find seats nobody uses.
    3. POST /copilot/billing/selected_users adds seats; DELETE cancels them (the seat lasts until the end of the billing cycle). selected_teams does the same for teams. The token needs manage_billing:copilot.

    🧪 Simulation for learning. Screens are simplified versions of Visual Studio Code and github.com with GitHub Copilot; names, files and suggestions are examples. Not affiliated with GitHub or Microsoft, and nothing here touches your real account.

    😟 THE PROBLEM

    You pay for 200 seats and suspect 40 are unused.

    😊 THE SOLUTION

    Use the seats API to find inactive users and the audit log to track changes.

    • Paying for idle seats✓ last_activity_at
    • Clicking seat by seat✓ POST / DELETE selected_users
    • Who changed what?✓ action:copilot in the audit log
    🛠️ Solved with: Seats API + audit log

    Start with a question

    We pay for 120 Copilot seats. Finance asks how many people actually use them, and security asks who switched off the public code filter. Where do I look?

    Think of an office building. The front desk keeps a visitor book: who came in, when, which floor. And the facilities team has a badge list: who has a badge, and when each badge last opened a door.

    GitHub gives a Copilot admin both. The audit log is the visitor book: every Copilot settings change, seat change and content exclusion change, with who did it and when. The Copilot user management REST API is the badge list: every seat, when it was last used, and calls to hand out or take back seats in bulk.

    Explain it like I’m 10

    The technical explanation

    Audit log events for Copilot

    Organization owners open the Audit log page in the organization settings. Copilot events have names that start with copilot., so the search action:copilot filters to them. You’ll see things like:

    • a seat added or cancelled for a user or team
    • a Copilot policy changed (for example, a feature enabled or disabled)
    • content exclusion settings changed

    Each entry has the actor, the action, the time and details. You can export the results. Event names change over time, so check the docs’ list of audit log events rather than memorising each one. For the exam, remember the prefix and the search.

    The Copilot user management REST API

    All the endpoints sit under /orgs/{org}/copilot/billing. With the GitHub CLI, gh api makes the calls for you:

    Method and pathWhat it does
    GET /orgs/{org}/copilot/billingSubscription settings and a seat breakdown for the org
    GET /orgs/{org}/copilot/billing/seatsEvery seat with assignee, last_activity_at and last_activity_editor
    POST /orgs/{org}/copilot/billing/selected_usersAdd seats for selected_usernames
    DELETE /orgs/{org}/copilot/billing/selected_usersCancel seats for selected_usernames
    POST / DELETE /orgs/{org}/copilot/billing/selected_teamsThe same, for selected_teams
    GET /orgs/{org}/copilot/metricsUsage metrics for the org

    Finding an unused seat:

    gh api /orgs/contoso/copilot/billing/seats
    # { "total_seats": 3, "seats": [
    #   { "assignee": { "login": "chen-qa" },
    #     "last_activity_at": "2026-09-02T09:12:00Z",
    #     "last_activity_editor": "jetbrains/2026.2" }, ... ] }

    Giving one person a seat and taking one away:

    gh api -X POST /orgs/contoso/copilot/billing/selected_users -f "selected_usernames[]=dina-new"
    # { "seats_created": 1 }
    gh api -X DELETE /orgs/contoso/copilot/billing/selected_users -f "selected_usernames[]=chen-qa"
    # { "seats_cancelled": 1 }

    Three rules to remember:

    1. The token needs the manage_billing:copilot scope.
    2. Adding and cancelling by user or team applies when the org gives Copilot to selected members and teams, not “all members”.
    3. A cancelled seat goes into pending cancellation and keeps working until the end of the billing cycle.
    1. 1 List seats

      GET .../copilot/billing/seats

    2. 2 Spot idle ones

      last_activity_at older than 60 days, or empty.

    3. 3 Cancel

      DELETE .../selected_users with their usernames.

    4. 4 Add new joiners

      POST .../selected_users or assign their team.

    5. 5 Prove it

      The audit log shows each change under action:copilot.

    A monthly seat review at Contoso
    Architect level Automate the review, keep a human in it

    You can run the seat review on a schedule, for example a GitHub Actions workflow that calls the seats endpoint once a month and opens an issue listing seats with no activity in 60 days. Don’t let the script cancel seats on its own: someone on leave or using an editor that reports activity late would lose access. Let a manager confirm, then cancel with one API call. Keep the token in an Actions secret, scoped to just what the job needs, and the audit log will show the cancellations with the token’s owner as the actor.

    Real-world business scenario

    Online retail

    Contoso (fictional)

    The problem
    Contoso paid for 120 Copilot Business seats but nobody knew who used them, and security couldn't tell who had changed the public code policy.
    What they used
    A monthly workflow that calls GET /orgs/contoso/copilot/billing/seats, an issue listing seats idle for 60 days, DELETE selected_users for confirmed ones, team-based seats for new joiners through selected_teams, and audit log searches with action:copilot.
    Why that choice
    The seats endpoint shows real usage per person, team seats remove the ticket for every new joiner, and the audit log answers 'who changed what' without guesswork.
    The result
    Contoso cancelled 18 idle seats in the first review, new developers get Copilot the day they join a team, and security can trace every Copilot policy change.

    When to use it and when not to

    ✓ Use it when…

    • Auditing who changed a Copilot policy, seat or content exclusion, with action:copilot.
    • Finding idle seats with last_activity_at before a renewal.
    • Adding or cancelling many seats in a script, or tying seats to a team.

    ✕ Think twice when…

    • Expecting a seat cancelled by API to stop working immediately.
    • Auto-cancelling seats with no human check.
    • Storing the manage_billing:copilot token in code or a shared file.

    ↔ Alternatives to consider

    • Organization settings › Copilot › Access for a handful of seat changes by hand.
    • The Copilot metrics API and dashboard for adoption trends rather than per-seat activity.
    Ready for more?The full lesson adds the technical explanation, when to use it, interview questions and revision notes.

    Test yourself with exercises

    5 original practice questions in the GH-300 style. Pick your answers, then check them. You will see why each option is right or wrong. Score 75% or more and this topic is marked complete.

    Question 1

    Question 1 of 5

    A compliance officer asks who changed a Copilot policy in the organization last month. What should an organization owner do?

    Question 2

    Question 2 of 5

    You need to identify Copilot seats in an organization that have not been used recently by using the REST API. Which endpoint and field should you use?

    Question 3

    Question 3 of 5

    An administrator cancels a user's Copilot seat on the fifth day of the billing cycle by calling DELETE /orgs/{org}/copilot/billing/selected_users. When does the user lose access to Copilot?

    Question 4

    Question 4 of 5 · Select 2

    An organization gives Copilot to selected members and teams. You need to grant Copilot seats to every member of the web team by using the REST API. Which TWO items are required?

    Question 5

    Question 5 of 5

    Which audit log search returns events related to Copilot seat assignments, Copilot policy changes, and Copilot content exclusion changes in an organization?

    Interview preparation

    Say your answer out loud first, then open the model answer. Interviewers care more about your reasoning than the exact words.

    Beginner Someone turned off Copilot Chat on github.com for the whole org last week. How do you find out who?

    Model answer

    Open the organization's audit log and search action:copilot. Copilot policy changes are logged there with the actor and the time.

    Interviewer follows up

    What else shows up there for Copilot?

    You

    Seats being added or cancelled, policy changes and content exclusion changes.

    Intermediate How would you find Copilot seats nobody is using?

    Model answer

    Call GET /orgs/contoso/copilot/billing/seats and look at last_activity_at on each seat. An old date, or no date at all, means the person isn't using it. last_activity_editor tells me which editor they last used.

    Experienced developer You cancel a seat on the 3rd of the month with the REST API. When does the user lose Copilot?

    Model answer

    At the end of the current billing cycle. The DELETE call returns seats_cancelled and the seat goes into pending cancellation, but it stays usable until the cycle ends.

    Interviewer follows up

    And what token do you need?

    You

    One with the manage_billing:copilot scope, from someone allowed to manage Copilot billing for the org, like an owner or billing manager.

    Scenario Every new developer joins the "web" team. How do you make sure they all get Copilot without a ticket each time?

    Model answer

    Assign seats to the team instead of to people: POST /orgs/contoso/copilot/billing/selected_teams with selected_teams set to web. Anyone added to the team gets a seat, and anyone removed loses it at the end of the cycle.

    Architecture & design Design a monthly Copilot licence review for an org with 800 seats.

    Model answer

    A scheduled workflow calls the seats endpoint, flags seats with no activity in, say, 60 days, and opens an issue listing them for managers to confirm. Confirmed ones are cancelled with DELETE selected_users. The metrics endpoint shows overall usage for the report, and the audit log, searched with action:copilot, proves who changed what.

    Quick revision

    Key points

    • Copilot audit log events start with copilot. Search action:copilot.
    • Logged events include seats added or cancelled, policy changes and content exclusion changes.
    • GET /orgs/{org}/copilot/billing shows the subscription settings and seat counts.
    • GET /orgs/{org}/copilot/billing/seats lists seats with last_activity_at and last_activity_editor.
    • POST or DELETE /orgs/{org}/copilot/billing/selected_users (selected_usernames) or /selected_teams (selected_teams) add or cancel seats.
    • Token scope manage_billing:copilot. A cancelled seat lasts until the end of the billing cycle.
    • /orgs/{org}/copilot/metrics returns usage metrics.

    Important terminology

    Audit log
    The organization's record of who did what and when, including Copilot settings, seat and content exclusion changes.
    action:copilot
    The audit log search qualifier that filters the log to Copilot events, whose names start with copilot.
    Copilot user management API
    REST endpoints under /orgs/{org}/copilot/billing to read Copilot settings, list seats and add or cancel seats.
    last_activity_at
    A field on each seat returned by the seats endpoint, showing when the user last used Copilot. Empty if they never have.
    selected_users
    The endpoint that adds seats (POST) or cancels seats (DELETE) for a list of usernames in selected_usernames.
    manage_billing:copilot
    The token scope needed to call the Copilot user management endpoints for an organization.
    Pending cancellation
    The state of a cancelled seat. The user keeps Copilot until the end of the current billing cycle.

    Common mistakes

    • Expecting a cancelled seat to stop working immediately.
    • Using PATCH or PUT for seats. Adding is POST, cancelling is DELETE.
    • Looking for Copilot settings changes in the repository's history instead of the organization audit log.

    Exam tips

    • "Who changed a Copilot policy?" = audit log, search action:copilot.
    • "Find inactive seats" = GET .../copilot/billing/seats and last_activity_at.
    • "Give a team Copilot by API" = POST .../copilot/billing/selected_teams.
    • "Scope for the token" = manage_billing:copilot.

    Five quick revision questions

    1. 1.Which search finds Copilot events in the audit log?Show

      action:copilot

    2. 2.Which field shows when a seat was last used?Show

      last_activity_at.

    3. 3.Which HTTP method cancels seats for users?Show

      DELETE on /orgs/{org}/copilot/billing/selected_users.

    4. 4.When does a cancelled seat stop working?Show

      At the end of the current billing cycle.

    5. 5.Which token scope do the seat endpoints need?Show

      manage_billing:copilot.

    Official references

    Finished this lesson? Tick it off. Your progress is saved in this browser.

    Next up: How Copilot Handles Your Data

    Studying with a friend? Send them this lesson

    It's free and needs no sign-up. Their progress saves in their own browser.

    Lesson done? Make it stick with a quick gameSort It, Match the Pairs, Lightning Round and Who Am I? Earn XP and badges. Play ❯

    Install MSDEVBUILD Azure

    Free · no account · works offline

    Save the whole course for offline ›

    Hi, I’m your Nimbus

    Your study buddy. Pick what we do next.

    MSDEVBUILD · Multi-Stack Dev Build

    Sign in to MSDEVBUILD

    One account for Azure certifications and the blog: sign in here and you are signed in on both. Your XP, streak, practice deck and certificate stay in sync on every device. Optional: everything works without an account.