Getting Started
This guide walks you through authenticating with the ZopNight API and making your first request.
Prerequisites
- A ZopNight account with at least one organization
- At least one connected cloud account (AWS, GCP, or Azure)
- An API client or
curlfor making HTTP requests
Base URL
All API requests are made to the gateway endpoint:
https://zopnight.com/apiOrganization Context
You do not need to include your organization ID in API requests. The gateway extracts it from your JWT token and automatically injects it into the request path before routing to backend services.
Authentication
First, obtain an access token by logging in. ZopNight supports email/password, Google, GitHub, and SAML authentication.
Step 1: Login
Requestbash
curl -X POST https://zopnight.com/api/auth/login \
-H "Content-Type: application/json" \
-d '{
"email": "you@company.com",
"password": "your-password",
"provider": "email"
}'Responsejson
{
"data": {
"accessToken": "eyJhbGciOiJSUzI1NiIs...",
"refreshToken": "dGhpcyBpcyBhIHJlZnJl...",
"tenants": [
{
"id": "org_abc123",
"name": "My Organization"
}
],
"user": {
"email": "you@company.com",
"name": "Your Name"
}
}
}Step 2: Use the Token
Include the access token in all subsequent requests via the Authorization header:
Authenticated requestbash
curl https://zopnight.com/api/resources \
-H "Authorization: Bearer eyJhbGciOiJSUzI1NiIs..."See the full Authentication guide for token refresh, SSO, and more.
Response Format
All API responses are wrapped in a standard envelope:
Success responsejson
{
"data": {
"id": "sch_abc123",
"name": "Business Hours"
}
}Error responsejson
{
"error": {
"message": "schedule not found"
}
}Pagination
List endpoints support pagination via query parameters:
| Parameter | Type | Description |
|---|---|---|
page | integer | Page number (default: 1) |
limit | integer | Items per page (default: 20) |
sort_by | string | Field to sort by |
sort_order | string | asc or desc |
Examplebash
curl "https://zopnight.com/api/resources?page=2&limit=50&sort_by=name&sort_order=asc" \
-H "Authorization: Bearer <token>"Your First API Call
Let's list your discovered cloud resources:
List resourcesbash
curl https://zopnight.com/api/resources \
-H "Authorization: Bearer <token>"Responsejson
{
"data": [
{
"id": "res_001",
"name": "web-server-prod",
"uid": "i-0abc123def456",
"type": "aws-ec2",
"provider": "aws",
"region": "us-east-1",
"status": "running",
"instanceType": "t3.medium",
"schedulable": true,
"tags": { "Environment": "production" }
}
]
}