Back to Smithery

Create a team API key

docs-api-reference-organizations-create-a-team-api-key.md

latest6.3 KB
Original Source

POST

/

organizations

/

{orgId}

/

api-keys

Try it

JavaScript

JavaScript

import Smithery from '@smithery/api';

const client = new Smithery({
  apiKey: process.env['SMITHERY_API_KEY'], // This is the default and can be omitted
});

const apiKey = await client.organizations.apiKeys.create('orgId', { name: 'x' });

console.log(apiKey.id);
curl --request POST \
  --url https://api.smithery.ai/organizations/{orgId}/api-keys \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>"
}
'
import requests

url = "https://api.smithery.ai/organizations/{orgId}/api-keys"

payload = { "name": "<string>" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.smithery.ai/organizations/{orgId}/api-keys",
  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' => '<string>'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$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://api.smithery.ai/organizations/{orgId}/api-keys"

	payload := strings.NewReader("{\n \"name\": \"<string>\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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://api.smithery.ai/organizations/{orgId}/api-keys")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n \"name\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.smithery.ai/organizations/{orgId}/api-keys")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body

201

400

401

403

{
  "id": "<string>",
  "name": "<string>",
  "key": "<string>",
  "createdAt": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}

Authorizations

[​

](#authorization-authorization)

Authorization

string

header

required

Smithery API key as Bearer token

Path Parameters

[​

](#parameter-org-id)

orgId

string

required

Body

application/json

[​

](#body-name)

name

string

required

Name for the team API key

Required string length: 1 - 256

Response

201

application/json

API key created (key value only shown on creation)

[​

](#response-id)

id

string

required

[​

](#response-name)

name

string

required

[​

](#response-key)

key

string

required

[​

](#response-created-at)

createdAt

string

required

Was this page helpful?

YesNo

⌘I

JavaScript

JavaScript

import Smithery from '@smithery/api';

const client = new Smithery({
  apiKey: process.env['SMITHERY_API_KEY'], // This is the default and can be omitted
});

const apiKey = await client.organizations.apiKeys.create('orgId', { name: 'x' });

console.log(apiKey.id);
curl --request POST \
  --url https://api.smithery.ai/organizations/{orgId}/api-keys \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "name": "<string>"
}
'
import requests

url = "https://api.smithery.ai/organizations/{orgId}/api-keys"

payload = { "name": "<string>" }
headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

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

print(response.text)
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.smithery.ai/organizations/{orgId}/api-keys",
  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' => '<string>'
  ]),
  CURLOPT_HTTPHEADER => [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
  ],
]);

$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://api.smithery.ai/organizations/{orgId}/api-keys"

	payload := strings.NewReader("{\n \"name\": \"<string>\"\n}")

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

	req.Header.Add("Authorization", "Bearer <token>")
	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://api.smithery.ai/organizations/{orgId}/api-keys")
  .header("Authorization", "Bearer <token>")
  .header("Content-Type", "application/json")
  .body("{\n \"name\": \"<string>\"\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.smithery.ai/organizations/{orgId}/api-keys")

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

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"name\": \"<string>\"\n}"

response = http.request(request)
puts response.read_body

201

400

401

403

{
  "id": "<string>",
  "name": "<string>",
  "key": "<string>",
  "createdAt": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}
{
  "error": "<string>"
}