Migrate from v1 to v2
Transitioning to Datadog API v2 requires updating authentication, request formats, and endpoint URLs for metrics, logs, and traces.
What Changed
Authentication Method
API key authentication is deprecated in v2. Use application keys or OAuth for authentication.
headers = {'DD-API-KEY': 'YOUR_API_KEY'}headers = {'Authorization': 'Bearer YOUR_APP_KEY'}Request Payload Format
The structure for submitting metrics and logs has changed significantly. JSON payloads are now the standard.
data = [{'metric': 'my.metric', 'points': [[timestamp, value]]}]data = {'series': [{'metric': 'my.metric', 'points': [[timestamp, value]]}]}Endpoint URL Updates
Several API endpoints have been updated or replaced in v2, particularly for metrics, logs, and trace submission.
/api/v1/series
/api/v2/series
Migration Steps
- 1
Review Datadog API v2 Documentation
codeFamiliarize yourself with the v2 API documentation, paying close attention to authentication, request/response formats, and new endpoints. Understand the scope of changes compared to v1.
- ↳Focus on changes in authentication and data submission endpoints.
- ↳Note rate limits and pagination differences in v2.
- 2
Update Authentication Credentials
configGenerate and configure new application keys or OAuth tokens in your Datadog account. Update your application's configuration or environment variables to use these new credentials.
- ↳Securely store your new API keys/tokens.
- ↳Ensure your CI/CD pipeline is updated with the new secrets.
- 3
Modify API Request Logic
codeAdapt your code to the new v2 API structure. This involves changing how you construct request payloads for metrics, logs, and traces, and updating the target endpoint URLs.
- ↳Use Datadog's official SDKs if available, as they often handle version differences.
- ↳Consider using a library for JSON manipulation to simplify payload construction.
- 4
Implement Error Handling for v2
codeUpdate your error handling logic to account for new error codes and response formats in v2. This ensures graceful degradation and easier debugging when issues arise.
- ↳Log detailed error messages from the Datadog API.
- ↳Map v2 error codes to your internal alerting system.
- 5
Develop and Run Integration Tests
testWrite comprehensive integration tests that cover the modified API interactions. These tests should validate data submission, retrieval, and error scenarios against a test Datadog environment or mock service.
- ↳Use a dedicated testing environment or sandbox account.
- ↳Test edge cases and rate limiting behavior.
- 6
Phased Rollout and Monitoring
deployDeploy the updated code to a small subset of your environment first. Closely monitor performance, error rates, and Datadog ingestion metrics during the rollout.
- ↳Have a rollback plan ready.
- ↳Monitor Datadog's own status page for any reported issues.
- 7
Full Deployment and Verification
deployOnce confident, deploy the v2 integration across your entire environment. Continue to monitor key metrics and verify that data is being ingested correctly in Datadog.
- ↳Confirm data in Datadog dashboards match expected values.
- ↳Inform relevant teams about the migration completion.
Testing Checklist
- 1.
Authentication Success
Send a simple API request and verify a 2xx response code.
- 2.
Data Ingestion (Metrics)
Submit sample metric data and confirm its appearance in Datadog Metrics Explorer.
- 3.
Data Ingestion (Logs)
Send sample log events and verify they are searchable in Datadog Logs.
- 4.
Data Ingestion (Traces)
Submit sample trace data and check its visibility in Datadog APM.
- 5.
Error Response Handling
Simulate invalid requests and verify correct error codes and messages are returned.
- 6.
Pagination and Rate Limits
Test fetching large datasets and monitor responses for rate limit headers.
Common Mistakes
✗ Continuing to use v1 API keys for authentication.
API requests will fail with authentication errors.
✓ Generate and use Datadog application keys or OAuth tokens for v2 authentication.
✗ Not updating the request payload structure for metrics/logs.
Datadog will reject the data with malformed payload errors.
✓ Strictly adhere to the JSON schema defined in the v2 API documentation for submitting data.
✗ Forgetting to update endpoint URLs in the code.
Requests will result in 404 Not Found errors.
✓ Carefully review the v2 API documentation for the correct endpoint paths.
✗ Ignoring new error codes or response formats from v2.
Runtime errors might go unhandled, leading to application instability.
✓ Update error handling logic to parse and react to v2-specific error responses.
Never get blindsided by an API change again
Deprecatr AI monitors 150+ providers, maps changes to your codebase, and delivers migration checklists before your team hits a breaking change.
Join the Waitlist