Boffin Codersts-netstorageapi-akamaiby Boffin Coders

Start here

NetStorage basics

New to the NetStorage HTTP API? This page covers the setup and the rules that trip people up on their first request. It summarises Akamai's documentation, linked in each section.

The four things you need

Client optionAkamai termWhat it isWhere to find it
hostnameConnection hostname (HTTP Domain Name)The API endpoint, always [domain prefix]-nsu.akamaihd.net. The prefix is chosen when the storage group is created.Control Center → NetStorage → Storage Groups → your group → HTTP Domain Name
keyNameUpload account name (uploadAccountId)The account that signs requests. It must not contain commas or spaces.NetStorage → Upload Accounts
keyHTTP API keyThe shared secret used to sign each request. It is never sent over the wire.Upload account → Access Methods → NetStorage HTTP CMS API → Copy Key
cpCodeCP code (upload directory)A numeric code that is the root directory of your storage group. Every path starts with it.Storage group details

Source: Key concepts and terms.

Enable API access

  1. In Control Center, go to Content delivery → Edge applications → NetStorage and open Upload Accounts.
  2. Add an upload account or edit an existing one. Its name is your keyName.
  3. In Access Methods, open the NetStorage HTTP CMS API tab and click Add HTTP API Key. A key is generated for you; Copy Key gives you the key.
  4. Open Storage Groups, select your group and note the HTTP Domain Name: that is your hostname.

Wait for propagation. A new or changed upload account can take up to 120 minutes to become active, and Akamai emails you when it is done. Requests before then fail with 403.

Source: Get started.

The endpoint

https://example-nsu.akamaihd.net/123456/static/app.js
        ^ hostname              ^ CP code
                                       ^ your path

Sources: Format an API call, Technical limits.

How each request is signed

The client does this for you, but knowing it helps when you debug a 403. Each request carries three headers:

HeaderContains
X-Akamai-ACS-ActionThe operation as a query string, starting with version=1, e.g. version=1&action=upload. One action per request.
X-Akamai-ACS-Auth-Data5, 0.0.0.0, 0.0.0.0, [unix time], [unique id], [keyName]. Version 5 means HMAC-SHA256, the cipher Akamai recommends.
X-Akamai-ACS-Auth-SignBase64 HMAC-SHA256, using your key, of the Auth-Data value, the request path, a newline, x-akamai-acs-action: plus the action value, and a final newline.

Keep your clock in sync. The time in the signature must be within one minute of Akamai's time, or the request fails with 403. Run NTP on servers and CI runners.

See it for yourself in the playground, which shows the exact string that gets signed. Source: Signature header authentication.

Limits worth knowing

LimitValue
Write operations (upload, delete, rename, mkdir, rmdir…)About 50 per second per storage group, averaged over 10 seconds
Read operations (download, stat…)About 1,000 per second per storage group
dir and listEach counts as 10 reads
Largest object150 GB; split files over 100 GB into parts
Path length800 characters, including directories
Concurrent connectionsUp to 90 per upload account

Akamai calls these recommended maximums rather than guarantees: rate limiting can start earlier, and three-replica storage groups allow fewer writes. Exceeding them returns 429; back off and retry. Very large directories can time out when listed, so page through them with max_entries. Source: Technical limits.

Replication and reading back

NetStorage keeps copies of your content in more than one place. The HTTP API does not chase requests to other replicas, so right after an upload, a stat or download can briefly see an older version or nothing at all. Akamai recommends serving content to users through a delivery product with NetStorage as the origin, and not downloading files larger than 1 GB through this API. This client also holds a download in memory before writing it, so plan memory for large files. Source: Technical limits.

Common errors

StatusUsually meansWhat to check
403Authentication or authorization failed, or the action is not allowed with that HTTP method.Clock within one minute; the right hostname, keyName and key; the upload account has finished propagating. The response body often says more.
404The path does not exist.The CP code and path; replication delay right after an upload.
412A precondition failed.The content changed since you last read it.
429Too many requests.Slow down and retry with backoff; see the limits above.
500An error on Akamai's side.Retry later; contact Akamai support with the response details if it persists.

Remember that the client resolves promise methods for HTTP errors; use the callback form to read res.statusCode. Source: Errors.

Next: install and configure the client →