DeprecatrAI

Migrate from v1 to v2

Transitioning to Datadog API v2 requires updating authentication, request formats, and endpoint URLs for metrics, logs, and traces.

within 90 days~8h effort3 breaking changes

What Changed

Critical

Authentication Method

API key authentication is deprecated in v2. Use application keys or OAuth for authentication.

Before
headers = {'DD-API-KEY': 'YOUR_API_KEY'}
After
headers = {'Authorization': 'Bearer YOUR_APP_KEY'}
High

Request Payload Format

The structure for submitting metrics and logs has changed significantly. JSON payloads are now the standard.

Before
data = [{'metric': 'my.metric', 'points': [[timestamp, value]]}]
After
data = {'series': [{'metric': 'my.metric', 'points': [[timestamp, value]]}]}
High

Endpoint URL Updates

Several API endpoints have been updated or replaced in v2, particularly for metrics, logs, and trace submission.

Before
/api/v1/series
After
/api/v2/series

Migration Steps

  1. 1

    Review Datadog API v2 Documentation

    code

    Familiarize 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. 2

    Update Authentication Credentials

    config

    Generate 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. 3

    Modify API Request Logic

    code

    Adapt 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. 4

    Implement Error Handling for v2

    code

    Update 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. 5

    Develop and Run Integration Tests

    test

    Write 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. 6

    Phased Rollout and Monitoring

    deploy

    Deploy 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. 7

    Full Deployment and Verification

    deploy

    Once 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. 1.

    Authentication Success

    Send a simple API request and verify a 2xx response code.

  2. 2.

    Data Ingestion (Metrics)

    Submit sample metric data and confirm its appearance in Datadog Metrics Explorer.

  3. 3.

    Data Ingestion (Logs)

    Send sample log events and verify they are searchable in Datadog Logs.

  4. 4.

    Data Ingestion (Traces)

    Submit sample trace data and check its visibility in Datadog APM.

  5. 5.

    Error Response Handling

    Simulate invalid requests and verify correct error codes and messages are returned.

  6. 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