# Request OTP

`POST /gate/otp/request` · Identity & Access · Sign-in & Sessions

Sends a 6-digit one-time password to the end-user's email address, initiating a passwordless sign-in or step-up flow. The OTP code has a 5-minute TTL and is single-use. Returns 202 Accepted regardless of whether the email matches an existing end-user, preventing enumeration.

## Parameters

| Name | In | Required | Description |
|---|---|---|---|
| `projectSlug` | path | yes | The project's slug: the path segment after `@`. It is unique within the org. Example: `"storefront"`. |

## Request body

| Field | Type | Required | Description |
|---|---|---|---|
| `email` | string (email) | yes | The address to send the code to. The response is the same whether or not an active end user has this address; a code is only emailed when one does. |
| `purpose` | enum ("signin", "magic_link", "password_reset", "mfa_challenge") | no | What the code is for. Default `signin`, the only purpose whose verify signs the end user in. A code is checked against requests with the same purpose only. |

```json
{
  "email": "jane@demo.example",
  "purpose": "signin"
}
```

## Responses

- **200**: Success

| Field | Type | Required | Description |
|---|---|---|---|
| `data` | object | yes | Confirms the request was accepted. When the address belongs to an active end user, the code is emailed to it. |
| `data.otp` | object | yes | The code request. It looks the same whether or not the address belongs to an end user. |
| `data.otp.id` | string | yes | An id for this code request (`euoc_...`). Every request gets one, registered address or not. Verify does not need it. |
| `data.otp.expiresAt` | string (date-time) | yes | When the code expires, 5 minutes from now. |
| `data.debugCode` | string | no | The code itself. Only in a test deployment that turns this on; a production deployment never includes it. |
| `meta` | object | yes | Request metadata: cost, timing and the request and trace ids. |


## Errors

| HTTP | Code | When |
|---|---|---|
| 404 | `K9O_END_USER_NOT_FOUND` | No account was found for the provided identity. |

## Code samples

### cURL

```bash
curl -X POST 'https://<org>.api-<region>.k9o.io/@storefront/gate/otp/request' \
  -H 'Content-Type: application/json' \
  -d '{
  "email": "jane@demo.example",
  "purpose": "signin"
}'
```

### fetch

```javascript
const res = await fetch('https://<org>.api-<region>.k9o.io/@storefront/gate/otp/request', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
  "email": "jane@demo.example",
  "purpose": "signin"
}),
});
const { data, meta } = await res.json();
```

### @k9o/core

```typescript
// const k9o = new K9o({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })
const { data } = await k9o.gate.passwordless.requestOtp({
  email: 'jane@demo.example',
  purpose: 'signin'
})
```

### k9o

```python
# k9o = create_client(org_slug="playground", project_slug="storefront", api_key="k9o_…")
response = k9o.gate.passwordless.request_otp({
    "email": "jane@demo.example",
    "purpose": "signin"
})
```

### sdk-go

```go
// ctx := context.Background()
// client, _ := k9o.NewClient(k9o.ClientOpts{OrgSlug: "playground", ProjectSlug: "storefront", APIKey: "k9o_…"})
data, _, kerr := client.Gate.Passwordless.RequestOtp(ctx, map[string]any{"email": "jane@demo.example", "purpose": "signin"})
```

### k9o

```rust
// let k9o = Client::new(ClientOpts { org_slug: "playground".into(), project_slug: "storefront".into(), api_key: "k9o_…".into() })?;
let resp = k9o.gate.passwordless.request_otp(json!({"email": "jane@demo.example", "purpose": "signin"})).await?
```

### dev.k9o:core

```java
// K9o k9o = K9o.createClient(K9o.Opts.builder().orgSlug("playground").projectSlug("storefront").apiKey("k9o_…").build());
var response = k9o.gate().passwordless().requestOtp(Map.of("email", "jane@demo.example", "purpose", "signin"))
```

### K9o.Core

```c#
// var k9o = K9oClient.Create(new K9oOptions { OrgSlug = "playground", ProjectSlug = "storefront", ApiKey = "k9o_…" });
var response = await k9o.Gate.Passwordless.RequestOtpAsync(new Dictionary<string, object> { ["email"] = "jane@demo.example", ["purpose"] = "signin" })
```

### k9o

```ruby
# k9o = K9o.create_client(org_slug: "playground", project_slug: "storefront", api_key: "k9o_…")
response = k9o.gate.passwordless.request_otp({ email: "jane@demo.example", purpose: "signin" })
```

### k9o/sdk

```php
// $k9o = K9oClient::create(['org_slug' => 'playground', 'project_slug' => 'storefront', 'api_key' => 'k9o_…']);
$response = $k9o->gate->passwordless->request_otp(['email' => 'jane@demo.example', 'purpose' => 'signin'])
```

### K9o

```swift
// let k9o = try K9o.createClient(orgSlug: "playground", projectSlug: "storefront", apiKey: "k9o_…")
let result = try await k9o.gate.passwordless.requestOtp({
  email: "jane@demo.example",
  purpose: "signin"
})
```

### core-kotlin

```kotlin
// val k9o = createClient { orgSlug = "playground"; projectSlug = "storefront"; apiKey = "k9o_…" }
val result = k9o.gate.passwordless.requestOtp({
  email: "jane@demo.example",
  purpose: "signin"
})
```

### k9o (Flutter)

```dart
// final k9o = K9o.createClient(orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…');
final result = await k9o.gate.passwordless.requestOtp({
  email: 'jane@demo.example',
  purpose: 'signin'
})
```

### @k9o/react-native

```javascript
// const k9o = createClient({ orgSlug: 'playground', projectSlug: 'storefront', apiKey: 'k9o_…' })  // RN, secure storage
const { data } = await k9o.gate.passwordless.requestOtp({
  email: 'jane@demo.example',
  purpose: 'signin'
})
```


Canonical page: https://docs.kilimanjaro.dev/api-playground/identity-access/request-otp
