Skip to main content
POST
/
v1
/
{workspace}
/
ws_api_key
/
Create API Key
curl -X POST "https://management-api.suprsend.com/v1/{workspace}/ws_api_key/" \
  --header 'Authorization: ServiceToken <SERVICE_TOKEN>' \
  --header 'Content-Type: application/json' \
  --data '{"name":"backend-prod","description":"Primary backend key"}'
import requests

url = "https://management-api.suprsend.com/v1/{workspace}/ws_api_key/"

payload = {
    "name": "backend-prod",
    "description": "Primary backend key"
}
headers = {
    "ServiceToken <token>": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {'ServiceToken <token>': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({name: 'backend-prod', description: 'Primary backend key'})
};

fetch('https://management-api.suprsend.com/v1/{workspace}/ws_api_key/', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://management-api.suprsend.com/v1/{workspace}/ws_api_key/",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'name' => 'backend-prod',
    'description' => 'Primary backend key'
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "ServiceToken <token>: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://management-api.suprsend.com/v1/{workspace}/ws_api_key/"

	payload := strings.NewReader("{\n  \"name\": \"backend-prod\",\n  \"description\": \"Primary backend key\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("ServiceToken <token>", "<api-key>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://management-api.suprsend.com/v1/{workspace}/ws_api_key/")
  .header("ServiceToken <token>", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"name\": \"backend-prod\",\n  \"description\": \"Primary backend key\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://management-api.suprsend.com/v1/{workspace}/ws_api_key/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["ServiceToken <token>"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"name\": \"backend-prod\",\n  \"description\": \"Primary backend key\"\n}"

response = http.request(request)
puts response.read_body
{
  "id": "ws_apik_exampleId01",
  "masked_api_key": "SS.XXXXXXX*****",
  "is_deleted": false,
  "name": "backend-prod",
  "allowed_domains": [],
  "created_at": "2026-04-21T12:19:00.148846Z",
  "created_by": {
    "name": "System User",
    "email": "org_XXXXXXXXXXXXXXXXXXXXXX@systemuser.suprsend.com"
  },
  "deleted_at": null,
  "deleted_by": null,
  "api_key": "SS.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
}
{
  "code": 123,
  "error_code": "<string>",
  "type": "<string>",
  "message": "<string>",
  "detail": "<string>"
}
{
  "code": 401,
  "error_code": "authentication_failed",
  "type": "AuthenticationFailed",
  "message": "Invalid service token.",
  "detail": "Invalid service token."
}
{
  "code": 404,
  "error_code": "not_found",
  "type": "NotFound",
  "message": "workspace 'demo' not found",
  "detail": "workspace 'demo' not found"
}

Authorizations

ServiceToken <token>
string
header
required

You can get Service Token from SuprSend dashboard -> Account Settings -> Service Tokens section.

Path Parameters

workspace
string
required

Workspace slug (e.g. staging, production).

Body

application/json
name
string
required

Label for the API key.

Example:

"backend-prod"

description
string | null

Optional notes for operators.

Response

API key created. api_key is returned only once - store it securely.

Workspace-scoped REST API key (server-side secret).

id
string

Unique identifier of the API key.

Example:

"ws_apik_exampleId01"

masked_api_key
string

Masked preview of the API key used in list responses.

Example:

"SS.XXXXXXX*****"

is_deleted
boolean

Indicates whether the API key has been deleted.

name
string

Label for the API key.

Example:

"backend-prod"

allowed_domains
string[]

Domains allowed to use this key.

created_at
string<date-time>

Timestamp when the API key was created.

created_by
object | null

Identity that performed an action (created, updated, rolled, deleted, rotated).

deleted_at
string<date-time> | null

Timestamp when the API key was deleted, if applicable.

deleted_by
object | null

Identity that performed an action (created, updated, rolled, deleted, rotated).

api_key
string

Full secret API key. Returned only once at creation - store it securely and never commit to source control.

Example:

"SS.XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"