> For clean Markdown content of this page, append .md to this URL. For the complete documentation index, see https://www.agentmail.to/docs/llms.txt.

# Register Passkey

POST https://api.agentmail.to/v0/credentials/register
Content-Type: application/json

Reference: https://agentmail.to/docs/api-reference/credentials/register

## Authentication

- `Authorization` header (bearer token, required) — Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Servers

- `https://api.agentmail.to` (prod, default)
- `https://x402.api.agentmail.to` (prod-x402)
- `https://mpp.api.agentmail.to` (prod-mpp)
- `https://api.agentmail.eu` (eu-prod)

## Request

### Body (application/json)

This endpoint expects a RegisterPasskeyRequest.

- `origin` (string, required)
- `options` (PublicKeyCredentialCreationOptions, required)
- `name` (string, optional)
- `client_id` (string, optional)

## Response

### 200

- `credential` (Credential, required)
- `registration` (RegistrationResponse, required)

## Errors

### 400 Validation Error

- `name` (string, required) — Name of error.
- `errors` (any, required) — Validation errors. Each entry has a path and a message identifying the invalid field.
- `code` (string, optional) — Stable, machine-readable error code in snake_case (for example, not_found or missing_permission). Branch on this rather than the message text.
- `message` (string, optional) — Error message.
- `fix` (string, optional) — The concrete next action that resolves the error.
- `docs` (string, optional) — Link to the error reference entry for this code.

### 403 Credential Forbidden Error

- `name` (string, required) — Name of error.
- `message` (string, required) — Error message.
- `code` (string, optional) — Stable, machine-readable error code in snake_case (for example, not_found or missing_permission). Branch on this rather than the message text.
- `fix` (string, optional) — The concrete next action that resolves the error.
- `docs` (string, optional) — Link to the error reference entry for this code.

### 404 Not Found Error

- `name` (string, required) — Name of error.
- `message` (string, required) — Error message.
- `code` (string, optional) — Stable, machine-readable error code in snake_case (for example, not_found or missing_permission). Branch on this rather than the message text.
- `fix` (string, optional) — The concrete next action that resolves the error.
- `docs` (string, optional) — Link to the error reference entry for this code.

### 409 Conflict Error

- `name` (string, required) — Name of error.
- `message` (string, required) — Error message.
- `code` (string, optional) — Stable, machine-readable error code in snake_case (for example, not_found or missing_permission). Branch on this rather than the message text.
- `fix` (string, optional) — The concrete next action that resolves the error.
- `docs` (string, optional) — Link to the error reference entry for this code.

## Types

### PublicKeyCredentialCreationOptions

- `rp` (PublicKeyCredentialRpEntity, required)
- `user` (PublicKeyCredentialUserEntity, required)
- `challenge` (string, required)
- `pubKeyCredParams` (list of PublicKeyCredentialParameters, optional)
- `excludeCredentials` (list of PublicKeyCredentialDescriptor, optional)
- `extensions` (map from string to any, optional)

### Credential

- `created_at` (datetime, required)
- `credential_id` (string, required)
- `organization_id` (string, required) — ID of organization.
- `type` (enum, required)
  - Allowed values: `password`, `totp`, `secret`, `signing_key`, `passkey`, `api_key`
- `updated_at` (datetime, required)
- `version` (integer, required)
- `auth` (ApiKeyAuth, optional)
- `client_id` (string, optional)
- `expires_at` (datetime, optional)
- `inbox_id` (string, optional)
- `last_used_at` (datetime, optional)
- `name` (string, optional)
- `origin` (string, optional)
- `pod_id` (string, optional)
- `public_key` (CredentialPublicKey, optional)
- `rp` (CredentialRp, optional)
- `totp` (TotpSettings, optional)
- `use_count` (integer, optional)
- `user` (CredentialUser, optional)

### RegistrationResponse

- `id` (string, required)
- `rawId` (string, required)
- `type` ("public-key", required)
- `response` (AuthenticatorAttestationResponse, required)
- `authenticatorAttachment` ("platform", required)
- `clientExtensionResults` (map from string to any, required)

### PublicKeyCredentialRpEntity

- `id` (string, optional)
- `name` (string, optional)

### PublicKeyCredentialUserEntity

- `id` (string, required)
- `name` (string, optional)
- `displayName` (string, optional)

### PublicKeyCredentialParameters

- `type` (string, required)
- `alg` (integer, required)

### PublicKeyCredentialDescriptor

- `id` (string, required)
- `type` (string, optional)
- `transports` (list of string, optional)

### ApiKeyAuth

- `in`: `header`
  - `name` (string, required)
  - `prefix` (string, optional)
- `in`: `query`
  - `name` (string, required)

### CredentialPublicKey

- `algorithm` (string, required)
- `jwk` (map from string to any, required)
- `webauthn_id` (string, optional)

### CredentialRp

- `id` (string, required)
- `name` (string, optional)

### TotpSettings

- `algorithm` (enum, optional)
  - Allowed values: `SHA1`, `SHA256`, `SHA512`
- `digits` (integer, optional)
- `period` (integer, optional)
- `issuer` (string, optional)

### CredentialUser

- `id` (string, optional)
- `name` (string, optional)
- `display_name` (string, optional)

### AuthenticatorAttestationResponse

- `clientDataJSON` (string, required)
- `attestationObject` (string, required)
- `authenticatorData` (string, required)
- `publicKey` (string, required)
- `publicKeyAlgorithm` (integer, required)
- `transports` (list of string, required)

## Examples

**Request**

```json
{
  "origin": "origin",
  "options": {
    "rp": {},
    "user": {
      "id": "id"
    },
    "challenge": "challenge"
  }
}
```

**Response**

```json
{
  "credential": {
    "created_at": "2024-01-15T09:30:00Z",
    "credential_id": "credential_id",
    "organization_id": "organization_id",
    "type": "password",
    "updated_at": "2024-01-15T09:30:00Z",
    "version": 1,
    "auth": {
      "in": "header",
      "name": "name",
      "prefix": "prefix"
    },
    "client_id": "client_id",
    "expires_at": "2024-01-15T09:30:00Z",
    "inbox_id": "inbox_id",
    "last_used_at": "2024-01-15T09:30:00Z",
    "name": "name",
    "origin": "origin",
    "pod_id": "pod_id",
    "public_key": {
      "algorithm": "algorithm",
      "jwk": {
        "jwk": {
          "key": "value"
        }
      },
      "webauthn_id": "webauthn_id"
    },
    "rp": {
      "id": "id",
      "name": "name"
    },
    "totp": {
      "algorithm": "SHA1",
      "digits": 1,
      "period": 1,
      "issuer": "issuer"
    },
    "use_count": 1,
    "user": {
      "id": "id",
      "name": "name",
      "display_name": "display_name"
    }
  },
  "registration": {
    "id": "id",
    "rawId": "rawId",
    "type": "public-key",
    "response": {
      "clientDataJSON": "clientDataJSON",
      "attestationObject": "attestationObject",
      "authenticatorData": "authenticatorData",
      "publicKey": "publicKey",
      "publicKeyAlgorithm": 1,
      "transports": [
        "transports",
        "transports"
      ]
    },
    "authenticatorAttachment": "platform",
    "clientExtensionResults": {
      "clientExtensionResults": {
        "key": "value"
      }
    }
  }
}
```

**SDK Code**

```python
import requests

url = "https://api.agentmail.to/v0/credentials/register"

payload = {
    "origin": "origin",
    "options": {
        "rp": {},
        "user": { "id": "id" },
        "challenge": "challenge"
    }
}
headers = {
    "Authorization": "Bearer <api_key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://api.agentmail.to/v0/credentials/register';
const options = {
  method: 'POST',
  headers: {Authorization: 'Bearer <api_key>', 'Content-Type': 'application/json'},
  body: '{"origin":"origin","options":{"rp":{},"user":{"id":"id"},"challenge":"challenge"}}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.agentmail.to/v0/credentials/register"

	payload := strings.NewReader("{\n  \"origin\": \"origin\",\n  \"options\": {\n    \"rp\": {},\n    \"user\": {\n      \"id\": \"id\"\n    },\n    \"challenge\": \"challenge\"\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("Authorization", "Bearer <api_key>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://api.agentmail.to/v0/credentials/register")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <api_key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"origin\": \"origin\",\n  \"options\": {\n    \"rp\": {},\n    \"user\": {\n      \"id\": \"id\"\n    },\n    \"challenge\": \"challenge\"\n  }\n}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://api.agentmail.to/v0/credentials/register")
  .header("Authorization", "Bearer <api_key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"origin\": \"origin\",\n  \"options\": {\n    \"rp\": {},\n    \"user\": {\n      \"id\": \"id\"\n    },\n    \"challenge\": \"challenge\"\n  }\n}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://api.agentmail.to/v0/credentials/register', [
  'body' => '{
  "origin": "origin",
  "options": {
    "rp": {},
    "user": {
      "id": "id"
    },
    "challenge": "challenge"
  }
}',
  'headers' => [
    'Authorization' => 'Bearer <api_key>',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://api.agentmail.to/v0/credentials/register");
var request = new RestRequest(Method.POST);
request.AddHeader("Authorization", "Bearer <api_key>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"origin\": \"origin\",\n  \"options\": {\n    \"rp\": {},\n    \"user\": {\n      \"id\": \"id\"\n    },\n    \"challenge\": \"challenge\"\n  }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Bearer <api_key>",
  "Content-Type": "application/json"
]
let parameters = [
  "origin": "origin",
  "options": [
    "rp": [],
    "user": ["id": "id"],
    "challenge": "challenge"
  ]
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://api.agentmail.to/v0/credentials/register")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```