# Retire Function

`DELETE /functions/{name}` · Core · Compute & Automation

Transitions a developer-deployed function's `status` to `retired`, making it no longer invocable. The function registry entry is retained for audit purposes, and the function name enters a 24-hour cooldown before it can be reused by a new deployment.

Returns `403 FORBIDDEN` with `context.reason: "extension_managed"` if the function's `source` is `"extension:*"`. Extension-owned function lifecycles are managed by the extension system and cannot be terminated through this endpoint.

Requires `PROJECT_ADMIN` minimum.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `name` | path | yes | The function's name, or a module's name to retire every operation in the module. A single operation of a module is named `<module>:<operation>`. Example: `"greet"`. |
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Responses

- **200**: Success

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | The retired function, now with status `retired`; or, when the name is a module's, every operation it retired. |
| _one of_ | | |  |
| `data.id` | string (uuid) | yes | The function's id, a UUID. It stays the same across redeploys. |
| `data.name` | string | yes | The function's name. A module's operations are named `<module>:<operation>`. |
| `data.runtime` | enum ("bun", "rust", "go", "tinygo", "zig", "assemblyscript", "c", "cpp") | yes | The language runtime: `bun`, `rust`, `go`, `tinygo`, `zig`, `assemblyscript`, `c` or `cpp`. |
| `data.tier` | enum ("gateway", "sandbox") | yes | Where the function runs: `gateway` or `sandbox`. |
| `data.entryPoint` | string | yes | The artifact key of the deployed code. |
| `data.version` | string | yes | The version label of the deploy. |
| `data.status` | enum ("deploying", "active", "error", "retired") | yes | `deploying` while the code is prepared, `active` once it can be invoked, `error` when preparing it failed (see `errorDetail`), `retired` after it was deleted. |
| `data.source` | string | yes | Who manages the function: `developer` for one you deployed, `extension:<slug>` for one an installed extension owns. |
| `data.description` | object | yes | What the function does. Null when none was given. |
| _one of_ | | |  |
| _or_ | | |  |
| `data.createdAt` | string (date-time) | yes | When the function was first deployed. |
| `data.deployedAt` | object | yes | When the current deploy became active. Null while it is deploying. |
| _one of_ | | |  |
| _or_ | | |  |
| `data.retiredAt` | object | yes | When the function was retired. Null unless `status` is `retired`. |
| _one of_ | | |  |
| _or_ | | |  |
| `data.errorDetail` | object | yes | Why the deploy failed. Null unless `status` is `error`. |
| _one of_ | | |  |
| _or_ | | |  |
| _or_ | | |  |
| `data.retired` | array of object | yes | Every live operation of the module, now retired. |
| `data.retired.[]id` | string (uuid) | yes | The function's id, a UUID. It stays the same across redeploys. |
| `data.retired.[]name` | string | yes | The function's name. A module's operations are named `<module>:<operation>`. |
| `data.retired.[]runtime` | enum ("bun", "rust", "go", "tinygo", "zig", "assemblyscript", "c", "cpp") | yes | The language runtime: `bun`, `rust`, `go`, `tinygo`, `zig`, `assemblyscript`, `c` or `cpp`. |
| `data.retired.[]tier` | enum ("gateway", "sandbox") | yes | Where the function runs: `gateway` or `sandbox`. |
| `data.retired.[]entryPoint` | string | yes | The artifact key of the deployed code. |
| `data.retired.[]version` | string | yes | The version label of the deploy. |
| `data.retired.[]status` | enum ("deploying", "active", "error", "retired") | yes | `deploying` while the code is prepared, `active` once it can be invoked, `error` when preparing it failed (see `errorDetail`), `retired` after it was deleted. |
| `data.retired.[]source` | string | yes | Who manages the function: `developer` for one you deployed, `extension:<slug>` for one an installed extension owns. |
| `data.retired.[]description` | object | yes | What the function does. Null when none was given. |
| _one of_ | | |  |
| _or_ | | |  |
| `data.retired.[]createdAt` | string (date-time) | yes | When the function was first deployed. |
| `data.retired.[]deployedAt` | object | yes | When the current deploy became active. Null while it is deploying. |
| _one of_ | | |  |
| _or_ | | |  |
| `data.retired.[]retiredAt` | object | yes | When the function was retired. Null unless `status` is `retired`. |
| _one of_ | | |  |
| _or_ | | |  |
| `data.retired.[]errorDetail` | object | yes | Why the deploy failed. Null unless `status` is `error`. |
| _one of_ | | |  |
| _or_ | | |  |
| `meta` | object | yes |  |


## Errors

| HTTP | Code | When |
|---|---|---|
| 401 | `K9O_INVALID_CREDENTIALS` | The request credentials are missing or invalid. |
| 401 | `K9O_SESSION_EXPIRED` | Your session has expired; sign in again to continue. |
| 403 | `K9O_ACCESS_DENIED` | PROJECT_ADMIN is required to retire functions, or the function is extension-managed and cannot be deleted via this endpoint. |
| 404 | `K9O_FUNCTION_NOT_FOUND` | No function with that name exists in this project, or it has already been retired. |

## Code samples

### cURL

```bash
curl -X DELETE 'https://<org>.api-<region>.k9o.io/@storefront/functions/<name>' \
  -H 'Authorization: Bearer $K9O_TOKEN'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/functions/<name>', {
  method: 'DELETE',
  headers: {
    'Authorization': `Bearer ${process.env.K9O_TOKEN}`
  },
});
const { data, meta } = await res.json();
```

### k9o CLI

```bash
k9o function delete <name>
```

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.functions.delete('greet')
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.functions.delete("greet")
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.Functions.Delete(ctx, "greet")
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.functions.delete("greet").await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.functions().delete("greet")
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.Functions.DeleteAsync("greet")
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.functions.delete("greet")
```

### k9o/sdk

```php
// $k9o = K9oClient::create(['org_slug' => 'playground', 'project_slug' => 'storefront', 'api_key' => 'k9o_…']);
$response = $k9o->functions->delete('greet')
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/core/retire-function
