cURL is the simplest way to test and interact with the Data Mammoth API from the command line. These examples provide a quick reference for common API operations that you can run directly in your terminal.
Setup
Set your API key as an environment variable:
bash
export DM_API_KEY="dm_key_abc123def456"Account
Get Account Details
bash
curl -X GET "https://api.datamammoth.com/v1/account" \
-H "Authorization: Bearer $DM_API_KEY" \
-H "Content-Type: application/json"Server Management
List All Servers
bash
curl -X GET "https://api.datamammoth.com/v1/servers" \
-H "Authorization: Bearer $DM_API_KEY"List Running Servers Only
bash
curl -X GET "https://api.datamammoth.com/v1/servers?status=running" \
-H "Authorization: Bearer $DM_API_KEY"Get Server Details
bash
curl -X GET "https://api.datamammoth.com/v1/servers/srv_abc123" \
-H "Authorization: Bearer $DM_API_KEY"Create a Server
bash
curl -X POST "https://api.datamammoth.com/v1/servers" \
-H "Authorization: Bearer $DM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "web-production",
"plan": "vps-standard",
"region": "us-east",
"os": "ubuntu-24.04",
"hostname": "web01.example.com",
"tags": ["production", "web"]
}'Start a Server
bash
curl -X POST "https://api.datamammoth.com/v1/servers/srv_abc123/actions" \
-H "Authorization: Bearer $DM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"action": "start"}'Stop a Server
bash
curl -X POST "https://api.datamammoth.com/v1/servers/srv_abc123/actions" \
-H "Authorization: Bearer $DM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"action": "stop"}'Restart a Server
bash
curl -X POST "https://api.datamammoth.com/v1/servers/srv_abc123/actions" \
-H "Authorization: Bearer $DM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"action": "restart"}'Update Server Name and Tags
bash
curl -X PATCH "https://api.datamammoth.com/v1/servers/srv_abc123" \
-H "Authorization: Bearer $DM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "web-staging",
"tags": ["staging", "web"]
}'Delete a Server
bash
curl -X DELETE "https://api.datamammoth.com/v1/servers/srv_abc123" \
-H "Authorization: Bearer $DM_API_KEY"Get Server Metrics
bash
curl -X GET "https://api.datamammoth.com/v1/servers/srv_abc123/metrics?metric=cpu&period=24h" \
-H "Authorization: Bearer $DM_API_KEY"Available Plans and Regions
List Plans
bash
curl -X GET "https://api.datamammoth.com/v1/plans" \
-H "Authorization: Bearer $DM_API_KEY"List Regions
bash
curl -X GET "https://api.datamammoth.com/v1/regions" \
-H "Authorization: Bearer $DM_API_KEY"List OS Images
bash
curl -X GET "https://api.datamammoth.com/v1/images" \
-H "Authorization: Bearer $DM_API_KEY"Billing
List All Invoices
bash
curl -X GET "https://api.datamammoth.com/v1/billing/invoices" \
-H "Authorization: Bearer $DM_API_KEY"List Unpaid Invoices
bash
curl -X GET "https://api.datamammoth.com/v1/billing/invoices?status=unpaid" \
-H "Authorization: Bearer $DM_API_KEY"Get Invoice Details
bash
curl -X GET "https://api.datamammoth.com/v1/billing/invoices/inv_2026_0042" \
-H "Authorization: Bearer $DM_API_KEY"Check Account Balance
bash
curl -X GET "https://api.datamammoth.com/v1/billing/balance" \
-H "Authorization: Bearer $DM_API_KEY"List Subscriptions
bash
curl -X GET "https://api.datamammoth.com/v1/billing/subscriptions" \
-H "Authorization: Bearer $DM_API_KEY"Support Tickets
List Open Tickets
bash
curl -X GET "https://api.datamammoth.com/v1/support/tickets?status=open" \
-H "Authorization: Bearer $DM_API_KEY"Create a Ticket
bash
curl -X POST "https://api.datamammoth.com/v1/support/tickets" \
-H "Authorization: Bearer $DM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"subject": "High CPU usage on web server",
"department": "technical",
"priority": "high",
"server_id": "srv_abc123",
"message": "CPU usage above 90% for the past 3 hours."
}'Reply to a Ticket
bash
curl -X POST "https://api.datamammoth.com/v1/support/tickets/tkt_12345/replies" \
-H "Authorization: Bearer $DM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "The issue has been resolved after optimizing MySQL queries."
}'Webhooks
Create a Webhook
bash
curl -X POST "https://api.datamammoth.com/v1/webhooks" \
-H "Authorization: Bearer $DM_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"url": "https://yourapp.example.com/webhooks/datamammoth",
"events": ["server.status_changed", "billing.invoice_created"],
"secret": "your_webhook_secret"
}'List Webhooks
bash
curl -X GET "https://api.datamammoth.com/v1/webhooks" \
-H "Authorization: Bearer $DM_API_KEY"Tips for Using cURL
jq for readable formatting:bash
curl -s -X GET "https://api.datamammoth.com/v1/servers" \
-H "Authorization: Bearer $DM_API_KEY" | jq .-i to include headers:bash
curl -i -X GET "https://api.datamammoth.com/v1/servers" \
-H "Authorization: Bearer $DM_API_KEY"-v for debugging:bash
curl -v -X GET "https://api.datamammoth.com/v1/servers" \
-H "Authorization: Bearer $DM_API_KEY"bash
curl -s -X GET "https://api.datamammoth.com/v1/servers" \
-H "Authorization: Bearer $DM_API_KEY" -o servers.jsonWhat to Do Next
- API Code Examples — Python — Python examples.
- API Code Examples — JavaScript — Node.js examples.
- API Code Examples — PHP — PHP examples.
- API Overview — Full API documentation.