API Key

Create and use an API Key to access the Noroff API.

The API Key model

PropTypeDefault
name
string
API Key
status
string
ACTIVE
key
string
-

Create an API Key

POST/auth/create-api-key

You can use this endpoint to create an API Key.

You do not need to provide any data in the request body, but you can optionally provide a name value.

Request
{
  "name": "My API Key name" // Optional
}

A successful response will return a 201 Created status code and the newly created API Key.

Request
{
  "data": {
    "name": "My API Key name", // Or "API Key" if no name was provided
    "status": "ACTIVE",
    "key": "be4ab55c-d5b0-44c3-8a11-67a7dafddd10" // The API Key
  },
  "meta": {}
}

Restrictions

  • If set, the name value must be less than 32 characters.

Types

PropTypeDefault
name
string
API Key

Using the API Key

You use the API Key by sending it in the X-Noroff-API-Key header, along with the access token of the requesting user.

const options = {
  headers: {
    Authorization: `Bearer ${accessToken}`,
    "X-Noroff-API-Key": apiKey.data.key
  }
}
 
const response = await fetch(`${NOROFF_API_URL}/social/posts`, options)
const data = await response.json()

API Key Tool

Use this tool to login or register with the Noroff API and retrieve an API key.