API keys API
An API key authenticates your requests to Steel. This endpoint creates a project key, which works in one project only. For the base URL and authentication, see API conventions. For the error codes, see Errors.
Endpoints
Create an API key
POST/v1/api-keys
Creates a project key. Authenticate with an organization key, which works across the organization.
A project key cannot create keys, and an organization key cannot create another organization key. The new key does not depend on the key that created it. When you revoke the organization key, the project key keeps working.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
projectId | string (uuid) · body | Yes | The project to bind the key to. It must be an active project of your organization. |
name | string · body | No | A label for the key.Default Default. |
scopeType | string · body | No | Must be project or left out.Default project. |
The response is 201:
Response
| Field | Type | Description |
|---|---|---|
id | string (uuid) | The ID of the key. |
key | string | The full secret of the key. |
name | string | The label of the key. |
projectId | string (uuid) or null | The key's project. |
scopeType | string | Always project. |
createdAt | string (date-time) | When the key was created. |
updatedAt | string (date-time) | When the key last changed. |
Without projectId, the response is 400. A project key gets 403. When the project is not active or not in your organization, the response is 404.
In these examples, STEEL_API_KEY holds an organization key, and STEEL_PROJECT_ID holds the ID of the project. Projects shows how to find the ID.
See API keys.
curl -X POST https://api.steel.dev/v1/api-keys \
-H "steel-api-key: $STEEL_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"projectId\": \"$STEEL_PROJECT_ID\", \"name\": \"ci\"}"import Steel from "steel-sdk";
const client = new Steel();
const apiKey = await client.apiKeys.create({
projectId: process.env.STEEL_PROJECT_ID,
name: "ci",
});
console.log(apiKey.id, apiKey.projectId);import os
from steel import Steel
client = Steel()
api_key = client.api_keys.create(
project_id=os.environ["STEEL_PROJECT_ID"],
name="ci",
)
print(api_key.id, api_key.project_id)package main
import (
"context"
"fmt"
"log"
"os"
"github.com/steel-dev/sdk/go"
)
func main() {
if err := run(context.Background()); err != nil {
log.Fatal(err)
}
}
func run(ctx context.Context) error {
client := steel.NewClient()
apiKey, err := client.APIKeys.New(ctx, steel.APIKeyNewParams{
ProjectID: steel.F(os.Getenv("STEEL_PROJECT_ID")),
Name: steel.F("ci"),
})
if err != nil {
return err
}
fmt.Println(apiKey.ID, apiKey.ProjectID)
return nil
}#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = steel_rs::Client::new();
let api_key = client
.api_keys()
.create(steel_rs::ApiKeyCreateParams {
project_id: Some(std::env::var("STEEL_PROJECT_ID")?),
name: Some("ci".to_owned()),
..Default::default()
})
.await?;
let project_id = api_key.project_id.unwrap_or_default();
println!("{} {project_id}", api_key.id);
Ok(())
}