Comment on page

API & Sponsor Keys


Users with portal accounts can generate two distinct types of keys for expanding the functionality of their accounts. Both Key types are portal-specific and cannot be shared across portals.
Skynet API Keys allow scripts and permissioned applications to use your portal account on your behalf. Because these allow nearly full access to your account, these keys should be kept private and not committed to code repos or shared with any other user.
Sponsor Keys allow others to download specific files on Skynet through a portal that only allows traffic from account holders. Sponsor Keys are not private, and currently their use case is for pointing traditional domain names at account-only portals using DNSLink.

Skynet API Keys

Generating a Skynet API Key

You'll need to be authenticated to a portal in order to generate a portal-specific Skynet API Key. From the dashboard, navigate to the Settings page using the navigation in the top right.
Finding the Settings page
Next, select the "Developer Settings" tab, then navigate to the "API Keys" section.
Provide a name for your new key (these are only used in the Dashboard) before pressing "Generate your API key". You can then copy your key. It will not be shown again, so if you lose your key, you will need to generate a new one.
Successful creation of a new Skynet API Key

Using a Skynet API Key

Usage with HTTP Requests

To use a Skynet API Key when calling a portal's API, you'll want to attach an HTTP header called Skynet-Api-Key to your request. When used curl, you command will look like this:
curl --location --request GET '' \
--header 'Skynet-Api-Key: ODN8BE48HJMU0123456789012345678901234567890123456789'

Usage with an SDK

Currently, Skynet API Keys are only supported in the javascript, nodeJS, python and substrate SDKs.
In SDKs that support Skynet API Keys, you'll typically initialize your client using the syntax for providing additional options. This is typically for server-side contexts. Avoid this usage in user-facing web apps where including your Skynet API Key would expose it to users.
In @skynetlabs/skynet-nodejs you initialize the client like this:
const { SkynetClient } = require('@skynetlabs/skynet-nodejs');
const client = new SkynetClient('', {skynetApiKey: SKYNET_API_KEY});

Usage with Deploy-to-Skynet Github Action

When using an account-only portal with the Deploy-to-Skynet Github Action, you'll need to provide two additional inputs in your workflow file: skynet-api-key and portal-url
Follow the instructions above to navigate to the "Developer Settings" tab of the "Settings" page in the dashboard. Next, give your Sponsor Key a label, add one or more Skylinks this key will sponsor, and click "Generate Your Sponsor Key." You can later use the Dashboard to update the list of sponsored skylinks.
Generating a Sponsor Key

Using Sponsor Keys

Currently, Sponsor Keys are used in conjunction with DNSLink to allow websites to host their app on an account-only Skynet portal, while still using a traditional domain name.
Following the instructions on the DNSLink page, you'll want to make one additional DNS entry.
At the same _dnslink subdomain that includes your dnslink=/skynet-ns/[skylink] TXT record, make a second TXT record with this format:

Updating Sponsor Keys using a Skynet API Key

We'll soon be exposing more functionality to the Sponsor Key which will make updating it with scripts very useful for some server-side applications.
This section will be expanded to document interacting with the Accounts API to manage your Sponsor Keys outside of the Dashboard UI.