Skip to content
Reference>REST API>/authentication

Authentication ​

All MetaKraftwerk REST API endpoints require authentication via a JSON Web Token (JWT). Before calling any API endpoint, you must obtain an access token by authenticating with your credentials.

See Also

Overview ​

The authentication flow follows a standard JWT-based approach:

  1. Send your credentials to the authentication endpoint.
  2. Receive an access token in the response.
  3. Include the token in the Authorization header of all subsequent API requests.

Endpoint ​

POST https://app.metakraftwerk.com/authentication

Request ​

Headers ​

HeaderValue
Content-Typeapplication/json

Body ​

FieldTypeRequiredDescription
strategystringYesAuthentication strategy. Use "local" for username/password authentication.
emailstringYesThe email address associated with your MetaKraftwerk user account.
passwordstringYesThe password for your MetaKraftwerk user account.
json
{
  "strategy": "local",
  "email": "your.email@example.com",
  "password": "your-password"
}

Response ​

Success — 201 Created ​

json
{
  "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6ImFjY2VzcyJ9...",
  "authentication": {
    "strategy": "local",
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6ImFjY2VzcyJ9..."
  },
  "user": {
    "id": 1,
    "email": "your.email@example.com"
  }
}
FieldTypeDescription
accessTokenstringThe JWT to use in subsequent API requests.
authenticationobjectAuthentication details including the strategy used.
userobjectBasic information about the authenticated user.

Error Responses ​

StatusConditionExample Message
401Invalid credentialsInvalid login
400Missing required fields'email' is required

Using the Access Token ​

Once obtained, include the access token in the Authorization header of every API request using the Bearer scheme:

Authorization: Bearer <ACCESS_TOKEN>

Token Expiration

JWTs have a limited lifetime. When your token expires, the API returns a 401 Not authenticated error. You must re-authenticate to obtain a new token.

Examples ​

cURL ​

bash
# Authenticate and extract the access token
ACCESS_TOKEN=$(curl -s -X POST "https://app.metakraftwerk.com/authentication" \
  -H "Content-Type: application/json" \
  -d '{
    "strategy": "local",
    "email": "your.email@example.com",
    "password": "your-password"
  }' | jq -r '.accessToken')

# Use the token in subsequent requests
curl -X GET "https://app.metakraftwerk.com/api/v1/projects" \
  -H "Authorization: Bearer $ACCESS_TOKEN"

JavaScript (Fetch) ​

javascript
// Authenticate
const authResponse = await fetch('https://app.metakraftwerk.com/authentication', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    strategy: 'local',
    email: 'your.email@example.com',
    password: 'your-password'
  })
});

const { accessToken } = await authResponse.json();

// Use the token in subsequent requests
const response = await fetch('https://app.metakraftwerk.com/api/v1/projects', {
  headers: { 'Authorization': `Bearer ${accessToken}` }
});

const projects = await response.json();

Permissions ​

API access is governed by user-level and project-level permissions. Even with a valid token, requests may be rejected if the user lacks the required permissions for the target resource. Common permission requirements include:

PermissionRequired For
Project accessAccessing any project-scoped resource
write_instancesCreating or updating instances
read_buildsDownloading build results
write_buildsStarting new builds

INFO

Permissions are assigned per project by an administrator. Contact your MetaKraftwerk administrator if you need additional access.