Choose the Right Interface
Use the API when you need imperative control from scripts, CI pipelines, or external platforms. In most Infrastructure as Code workflows, prefer Terraform first. Terraform provides declarative state management, repeatable plans, and safer drift handling. Use direct API calls when Terraform does not cover a required operation or when you need ad hoc or event-driven actions.Typical API Workflow
Many API integrations follow this order:- Authenticate with
POST /v2/api/login. - Capture the returned
CIDsession token. - Send authenticated requests with
CIDin theAuthorizationheader ascid <CID>. - Re-authenticate and refresh
CIDafter session expiration.
Prerequisites
- A Controller URL or IP address.
- A user account with permissions for the endpoints you call.
API Request Pattern
1
Authenticate with the login API
Send
POST /v2/api/login with username and password.2
Store the CID from the login response
Extract the session token and store it for subsequent requests.
3
Call API endpoints with the CID
Send
CID in the Authorization header as cid <CID>.4
Refresh the session when needed
If a request returns
"return": false, check "reason" and log in again to get a new CID before retrying.Response Format
Most v2 endpoints use a standard response shape:return:trueon success,falseon failure.results: response payload on success.reason: failure reason whenreturnisfalse.
Example Flows
- Bash
- Python
- Go