GitHub Installations
Manage GitHub installations, repositories, pull requests, and work manifests.
The Terrateam REST API allows you to programmatically interact with Terrateam installations, work manifests, repositories, and more. Use the API to integrate Terrateam into your CI/CD pipelines, build custom workflows, and automate infrastructure operations.
The Terrateam API uses a two-step authentication process:
The API key is long-lived and can only be used to obtain access tokens.
Use your API key to call the refresh endpoint and obtain an access token:
curl -X POST https://app.terrateam.io/api/v1/access-token/refresh \ -H "Authorization: Bearer YOUR_API_KEY"Response:
{ "token": "eyJhbGc..."}The access token inherits the capabilities you selected when creating the API key.
Use the access token for all API requests:
curl -X GET https://app.terrateam.io/api/v1/whoami \ -H "Authorization: Bearer YOUR_ACCESS_TOKEN"For scripts that make multiple API calls over time, you’ll need to refresh tokens regularly:
#!/bin/bashAPI_KEY="your_api_key_here"
# Function to get a fresh access tokenget_access_token() { curl -s -X POST https://app.terrateam.io/api/v1/access-token/refresh \ -H "Authorization: Bearer $API_KEY" | jq -r '.token'}
# Get initial tokenACCESS_TOKEN=$(get_access_token)
# Make API requests# Refresh token every 50 seconds to be safe (before 60s expiration)while true; do # Use the token curl -X GET https://app.terrateam.io/api/v1/whoami \ -H "Authorization: Bearer $ACCESS_TOKEN"
# Wait and refresh sleep 50 ACCESS_TOKEN=$(get_access_token)donehttps://app.terrateam.ioFor self-hosted installations, use your custom domain.
GitHub Installations
Manage GitHub installations, repositories, pull requests, and work manifests.
GitLab Installations
Manage GitLab installations, groups, repositories, and work manifests.
Access Tokens
Create, list, refresh, and delete API access tokens for authentication.
Key-Value Store
Store and retrieve persistent data across workflow runs using the KV store.
Authentication
Retrieve user information and manage authentication sessions.
Stacks
Retrieve stack information and dependencies for pull requests.
System & Admin
Admin operations, server configuration, task management, and system utilities.
Many list endpoints support pagination using the page and limit query parameters:
GET /api/v1/github/installations/{installation_id}/repos?limit=50&page=...Use q for search queries and d for sort direction (asc or desc):
GET /api/v1/github/installations/{installation_id}/work-manifests?q=terraform&d=descEndpoints with {vcs} path parameter accept:
github - For GitHub integrationsgitlab - For GitLab integrationsAPI requests are rate limited to prevent abuse and ensure fair usage. Requests exceeding the limit will receive 429 Too Many Requests.
If you encounter rate limits, implement exponential backoff and retry logic in your client applications.
The API uses standard HTTP status codes:
| Code | Description |
|---|---|
| 200 | Request successful |
| 400 | Bad request - Invalid parameters |
| 403 | Forbidden - Invalid or missing authentication |
| 404 | Resource not found |