For the complete documentation index, see llms.txt. This page is also available as Markdown.

API Integration

Cost Units API

North's Cost Units feature enables you to track and manage custom cost metrics within your cloud financial operations. With the Cost Units API, you can programmatically upload and retrieve cost unit data from outside the North UI, using secure API keys for authentication.

When to Use the API

Use the API when you want to:

  • Automate recurring metric uploads from an internal data pipeline or warehouse

  • Sync business metrics from a third-party system on a schedule

  • Retrieve Cost Unit data programmatically for custom dashboards or reports

  • Integrate metric uploads into CI/CD or ETL workflows

Creating API Keys

Before you can use the API, you need to create an API key within the North application. API keys provide secure, programmatic access to your cost unit data without requiring interactive authentication.

Key Management in the North UI

To create an API key within the North application:

  1. In the Streams tab in app.north.cloud, open a business unit and select Cost Units

  2. Click Create New, then select API Settings

  3. Click Generate API Key. If the business unit already has keys, click Add

  4. Enter a name for the key, for example "Production Pipeline" or "Weekly Sync". Click Next

  5. Optionally set an expiration date, up to 365 days from creation. Click Next

  6. Copy and save the API key immediately. The full key is only shown once at creation time and cannot be retrieved later.

  7. On the Test step, try the key with the code examples. Click Done

API keys use the format north_api_{secret_hash}.

Viewing API Keys

The API Keys section displays all active keys for your organization, including:

  • Key name

  • Date created

  • Expiration date (if set)

  • Last used timestamp

Revoking API Keys

To revoke a key, click the delete action next to the key you want to remove. Revoked keys are deactivated immediately, and API requests that use a revoked key are rejected.

Important: When you create a new API key, it will be displayed only once. Make sure to save it securely, as it cannot be retrieved later. If you lose an API key, you must create a new one and revoke the old key.

Each API key is scoped to your organization and provides access to all cost units within your account. The key is validated on every API request to ensure secure access to your data.

API Endpoints

The API provides two endpoints for interacting with your cost units:

  • GET /public/cost-units - Retrieve existing cost unit data

  • POST /public/cost-units - Update cost unit data with new metrics

Note: The API supports updating existing cost units only. To create a Cost Unit, use Manual entry or Import template in North.

Authentication

All API requests require authentication using an API key. Include your API key in the Authorization header of each request:

Authorization: ApiKey north_api_{your_key}

The API key is validated on every request. Requests with missing, invalid, expired, or revoked keys will receive a 403 response.

You must also include your account_number as a query parameter in all requests. The API validates that the account number matches the organization associated with your API key. You can find your account number in Settings, on the Integrations tab, in the Account ID column.

Base URL

https://api.north.cloud

GET /public/cost-units

Retrieve data from an existing cost unit.

GET /public/cost-units

Headers

Header
Required
Description

Authorization

Yes

Your API key in the following format: ApiKey <your-api-key>

Content-Type

No

Content type (not required for GET requests)

Query Parameters

Parameter
Required
Type
Description

account_number

Yes

string

Your AWS account number (validated against the API key's organization)

cost_unit_id

Yes

string

Cost Unit ID. Copy it from the Cost Unit card in North.

(e.g., bu-123:cu-456)

Example Request

Response

Success (200 OK):

Error Responses:

  • 400 Bad Request: Missing required parameters, invalid format, or business unit ownership validation failed

  • 403 Forbidden: Missing, invalid, expired, or revoked API key, or the API key does not have access to the requested resource

  • 500 Internal Server Error: An internal error occurred while processing your request

POST /public/cost-units

Update an existing cost unit with new data points. This endpoint supports both merging new data with existing data and completely replacing existing data.

POST /public/cost-units

Headers

Header
Required
Description

Authorization

Yes

Your API key: ApiKey {your_key}

Content-Type

Yes

Must be application/json

Query Parameters

Parameter
Required
Type
Description

account_number

Yes

string

Your AWS account number (validated against the API key's organization)

replace

No

boolean

When true, completely replaces existing data instead of merging. Default: false

Request Body

Field
Required
Type
Description

cost_unit_id

Yes

string

Cost Unit ID, copied from the Cost Unit card in North (required - updates only, no creation via the API).

data

Yes

array

List of data points with date and metric values

Data Point Structure

Each item in the data array must contain:

Field
Required
Type
Description

date

Yes

string (date)

YYYY-MM-DD for a daily cost unit (e.g., "2024-01-15"). YYYY-MM for a monthly cost unit (e.g., "2024-01").

metric

Yes

string

Metric value as string (will be validated as decimal number)

Example Request

Response

Success (200 OK):

Error Responses:

  • 400 Bad Request: Missing required fields, invalid date format, invalid metric value, or business unit ownership validation failed

  • 403 Forbidden: Missing, invalid, expired, or revoked API key, or the API key does not have access to the requested resource

  • 500 Internal Server Error: An internal error occurred while processing your request

Data Merging vs. Replacement

The POST endpoint supports two modes of operation:

  • Merge (default): When replace=false or omitted, new data points are merged with existing data. If a date already exists, the new metric value will update the existing value.

  • Replace: When replace=true, all existing data in the cost unit is completely replaced with the new data array. This is useful for removing dates from a cost unit by sending an array that excludes those dates.

Tip: Use replace=true when your cost unit must contain exactly the data points you send. Dates that are missing from your request are removed.

Data Validation Notes

When uploading data via the POST endpoint, keep in mind:

  • metadata and viewId fields are ignored if provided. Existing metadata is preserved.

  • Future dates are rejected. For daily granularity, the current date is also rejected.

  • Duplicate dates within a single request are rejected.

  • Metric values are rounded to 2 decimal places.

  • A response can be 200 OK even when some data points are rejected. Check errors_count in the response. Each rejected data point is listed in errors.

Examples

Retrieve a Cost Unit

Upload Data to a Cost Unit

Best Practices

  • Secure Your API Keys: Treat API keys like passwords. Store them securely and never commit them to version control or share them publicly.

  • Use Key Expiration: Set expiration dates on your API keys to ensure regular rotation and limit exposure if a key is compromised.

  • Monitor Key Usage: Regularly review your active API keys and revoke any that you do not need.

  • Validate Data Before Sending: Ensure dates match the cost unit granularity (YYYY-MM-DD for daily, YYYY-MM for monthly) and metric values are valid decimals.

  • Handle Errors Gracefully: Implement proper error handling in your integration to handle authentication failures, validation errors, and rate limiting.

Last updated

Was this helpful?