Skip to content
Pidgely Docs

API reference · API keys

Update an API key

PATCHhttps://api.pidgely.com/api-keys/{id}
View as Markdown

Renames an API key and/or replaces its IP allowlist. allowed_ips replaces the whole list; [] lifts the restriction. Changes apply within about 30 seconds. Permissions cannot be changed: create a new key instead.

Renames the key and/or replaces its IP allowlist. Send at least one field; allowed_ips replaces the whole list and [] lifts the restriction. The change applies within 30 seconds.

Authorization: Bearer pdg_…. An API key with full_access. A sending_access key gets 401 restricted_api_key.

Path parameters

Name Type Required Description
id string Yes Resource id UUID.

Body parameters

JSON object.

Name Type Required Description
name string No Display name.
allowed_ips string[] No Restrict the key to these IPv4/IPv6 addresses or CIDR networks (e.g. 203.0.113.7, 10.0.0.0/8). Requests from other addresses fail with 403 ip_not_allowed. Omitted or empty = any address.

Request

Node.js
import { Pidgely } from 'pidgely';

const pidgely = new Pidgely(process.env.PIDGELY_API_KEY);

const { data, error } = await pidgely.apiKeys.update('0199d7f1-3a5c-7b2e-9d4f-6e1a0c8b7d92', {
  name: 'Production (web)',
});
console.log(data ?? error);
Python
import os
import pidgely

pidgely.api_key = os.environ["PIDGELY_API_KEY"]

result = pidgely.ApiKeys.update("0199d7f1-3a5c-7b2e-9d4f-6e1a0c8b7d92", {
    "name": "Production (web)",
})
print(result)
PHP
<?php

require __DIR__ . '/vendor/autoload.php';

$pidgely = Pidgely::client(getenv('PIDGELY_API_KEY'));

$result = $pidgely->apiKeys->update('0199d7f1-3a5c-7b2e-9d4f-6e1a0c8b7d92', [
    'name' => 'Production (web)',
]);
var_dump($result);
Go
package main

import (
	"context"
	"fmt"
	"os"

	"github.com/pidgely/pidgely-go"
)

func main() {
	ctx := context.Background()
	client := pidgely.NewClient(os.Getenv("PIDGELY_API_KEY"))

	result, err := client.ApiKeys.Update(ctx, "0199d7f1-3a5c-7b2e-9d4f-6e1a0c8b7d92", &pidgely.UpdateApiKeyRequest{
		Name: "Production (web)",
	})
	if err != nil {
		panic(err)
	}
	fmt.Println(result)
}
Ruby
require "pidgely"

Pidgely.api_key = ENV["PIDGELY_API_KEY"]

result = Pidgely::ApiKeys.update("0199d7f1-3a5c-7b2e-9d4f-6e1a0c8b7d92", {
  name: "Production (web)"
})
puts result
cURL
curl -X PATCH 'https://api.pidgely.com/api-keys/0199d7f1-3a5c-7b2e-9d4f-6e1a0c8b7d92' \
  -H "Authorization: Bearer $PIDGELY_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "name": "Production (web)"
}'

Response

200 OK

JSON
{
  "object": "api_key",
  "id": "0199d7f1-3a5c-7b2e-9d4f-6e1a0c8b7d92",
  "name": "Production (web)",
  "permission": "sending_access",
  "prefix": "pdg_k3x7m2qa4bnp6c5d",
  "domain_id": "0199d7f0-1c2b-7e4d-a5f6-0b9c8d7e6f51",
  "allowed_ips": [
    "203.0.113.7",
    "198.51.100.0/24"
  ],
  "created_at": "2026-10-12 16:44:41.000000+00",
  "last_used_at": "2026-10-12 16:44:41.000000+00"
}

Response fields

Name Type Required Description
object string No Object type. One of api_key.
id string No Unique id (UUID). UUID.
name string No Display name.
permission string No full_access (default) or sending_access. One of full_access, sending_access.
created_at string No Timestamp in UTC (2026-10-12 16:44:41.000000+00).
last_used_at string | null No Timestamp in UTC, or null.
prefix string No Public token prefix (pdg_<prefix>), to recognise a key.
domain_id string | null No Domain the key is restricted to, if any. UUID.
allowed_ips string[] No Addresses (203.0.113.7) and CIDR networks (10.0.0.0/8) the key may be used from, over the API and SMTP. Empty = any address.

Errors

Errors have the shape {"statusCode", "name", "message"}. See Errors for the full list.

Status Name When
401 missing_api_key, restricted_api_key No Authorization: Bearer header, or a sending_access key called an endpoint that needs full_access.
403 invalid_api_key, validation_error The API key is invalid or revoked, or the request is not allowed for this account (unverified domain, plan limit, paused account).
404 not_found The resource does not exist in this account (or the id is not a valid UUID).
422 validation_error A field is missing or invalid; message names it.
429 rate_limit_exceeded Too many requests per second. Wait for Retry-After seconds.
422 validation_error Neither name nor allowed_ips was sent, or an allowed_ips entry is invalid.