Skip to content

Rotate API Key

POST /keys/rotate | Auth: Required

Rotate your API key. The current key is immediately invalidated and a new key is returned. Store the new key securely -- it will not be shown again.

Request

No body required. Authenticate with your current API key.

Response

FieldTypeDescription
successbooleanWhether the request succeeded
api_keystringThe new API key (prefixed with suwappu_sk_)
messagestringConfirmation message

Example Response

{

"hl-key">"success": true,

"hl-key">"api_key": "suwappu_sk_new_8f3a1b9c4d2e7f6a",

"hl-key">"message": "API key rotated. Old key is now invalid."

}

Warning: Your old API key is immediately invalidated the moment this request succeeds. All subsequent requests must use the new key. Store it securely -- you will not be able to retrieve it again.

Errors

StatusErrorCause
401"Unauthorized"Missing or invalid API key
500"Key rotation failed"Internal error during key generation

Code Examples

curl

-kw">curl -X POST https://api.suwappu.bot/v1/agent/keys/rotate \

-H -str">"Authorization: Bearer suwappu_sk_your_current_key"

Python

import requests

response = requests.post(

class="hl-str">"https:class="hl-commentclass="hl-str">">//api.suwappu.bot/v1/agent/keys/rotate",

headers={class="hl-str">"Authorization": class="hl-str">"Bearer suwappu_sk_your_current_key"},

)

data = response.json()

if data[class="hl-str">"success"]:

new_key = data[class="hl-str">"api_key"]

print(fclass="hl-str">"New key: {new_key}")

class=class="hl-str">"hl-comment"># IMPORTANT: Update your stored key immediately

class=class="hl-str">"hl-comment"># The old key no longer works

TypeScript

const response = await fetch(

class="hl-str">"https:class="hl-commentclass="hl-str">">//api.suwappu.bot/v1/agent/keys/rotate",

{

method: class="hl-str">"POST",

headers: {

Authorization: class="hl-str">"Bearer suwappu_sk_your_current_key",

},

}

);

const data = await response.json(); if (data.success) {

const newKey = data.api_key;

console.log(New key: ${newKey});

class=class="hl-str">"hl-comment">// IMPORTANT: Update your stored key immediately

class=class="hl-str">"hl-comment">// The old key no longer works

}