Managing users and teams
Create users, manage team membership, and query team projects and release groups via the FOSSA API.
Overview
These recipes cover common user and team management tasks that are useful for provisioning automation and integrations with identity systems.
Note
A FOSSA API token with Full access and sufficient permissions (organization admin or equivalent). See Authentication.
Listing users
# Paginated user list — page 1, 25 per pagecurl -G 'https://app.fossa.com/api/v2/users/' \ -d 'page=1' \ -d 'pageSize=25' \ -H 'Authorization: Bearer YOUR_API_KEY' # Search by name or emailcurl -G 'https://app.fossa.com/api/v2/users/' \ -d 'search=alice' \ -H 'Authorization: Bearer YOUR_API_KEY'Creating a user
curl --request POST \ --url 'https://app.fossa.com/api/users' \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "email": "alice@example.com", "full_name": "Alice Smith", "role": "member" }'To create the user and generate an API token in one request, include createFullApiToken or createPushOnlyApiToken:
curl --request POST \ --url 'https://app.fossa.com/api/users' \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "email": "ci-bot@example.com", "full_name": "CI Bot", "role": "member", "isServiceAccount": true, "createPushOnlyApiToken": true }'The response includes pushOnlyApiToken (or fullApiToken) directly; this is the only time the token is returned in plain text.
Deleting a user
curl --request DELETE \ 'https://app.fossa.com/api/users/123' \ -H 'Authorization: Bearer YOUR_API_KEY'Listing teams
# Paginated list of all teamscurl -G 'https://app.fossa.com/api/v2/teams/' \ -d 'page=1' \ -d 'pageSize=25' \ -H 'Authorization: Bearer YOUR_API_KEY'Creating a team
curl --request POST \ --url 'https://app.fossa.com/api/teams' \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "name": "Platform Security" }'Getting a team
curl 'https://app.fossa.com/api/teams/42' \ -H 'Authorization: Bearer YOUR_API_KEY'The response includes the team's member user IDs and associated project locators.
Listing team members
curl -G 'https://app.fossa.com/api/teams/42/members' \ -d 'page=1' \ -d 'pageSize=25' \ -H 'Authorization: Bearer YOUR_API_KEY'Adding and removing team members
Use PUT /api/teams/:id/users with a top-level action (add, replace, or remove) and a users array. Each user specifies an id and an optional roleId.
# Add a user to the team with a specific rolecurl --request PUT \ --url 'https://app.fossa.com/api/teams/42/users' \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "action": "add", "users": [ { "id": 123, "roleId": 2 } ] }' # Remove a user from the teamcurl --request PUT \ --url 'https://app.fossa.com/api/teams/42/users' \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "action": "remove", "users": [ { "id": 123 } ] }'Listing team projects
curl -G 'https://app.fossa.com/api/teams/42/projects' \ -d 'page=1' \ -d 'pageSize=25' \ -H 'Authorization: Bearer YOUR_API_KEY'Assigning projects to a team
PUT /api/teams/:id/projects updates the team's project list. Pass a projects array of locators and an action of add, remove, or replace. Use replace to set the full list of projects the team should own.
curl --request PUT \ --url 'https://app.fossa.com/api/teams/42/projects' \ --header 'Authorization: Bearer YOUR_API_KEY' \ --header 'Content-Type: application/json' \ --data '{ "action": "replace", "projects": [ "git+github.com/your-org/service-a", "git+github.com/your-org/service-b" ] }'Deleting a team
curl --request DELETE \ 'https://app.fossa.com/api/teams/42' \ -H 'Authorization: Bearer YOUR_API_KEY'