Create an email for a user
curl --request POST \
--url https://{tenant_id}.hanko.io/admin/users/{id}/emails \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"address": "jsmith@example.com",
"is_primary": true,
"is_verified": true
}
'import requests
url = "https://{tenant_id}.hanko.io/admin/users/{id}/emails"
payload = {
"address": "jsmith@example.com",
"is_primary": True,
"is_verified": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({address: 'jsmith@example.com', is_primary: true, is_verified: true})
};
fetch('https://{tenant_id}.hanko.io/admin/users/{id}/emails', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenant_id}.hanko.io/admin/users/{id}/emails",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'address' => 'jsmith@example.com',
'is_primary' => true,
'is_verified' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{tenant_id}.hanko.io/admin/users/{id}/emails"
payload := strings.NewReader("{\n \"address\": \"jsmith@example.com\",\n \"is_primary\": true,\n \"is_verified\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant_id}.hanko.io/admin/users/{id}/emails")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"address\": \"jsmith@example.com\",\n \"is_primary\": true,\n \"is_verified\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant_id}.hanko.io/admin/users/{id}/emails")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"address\": \"jsmith@example.com\",\n \"is_primary\": true,\n \"is_verified\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "802df042-1ac2-496d-af81-6ace729ed055",
"address": "jsmith@example.com",
"is_verified": true,
"is_primary": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"code": 400,
"message": "Bad Request"
}{
"code": 404,
"message": "Not found"
}{
"code": 409,
"message": "Conflict"
}{
"code": 500,
"message": "Internal Server Error"
}Email Management
Create an email for a user
POST
/
users
/
{id}
/
emails
Create an email for a user
curl --request POST \
--url https://{tenant_id}.hanko.io/admin/users/{id}/emails \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"address": "jsmith@example.com",
"is_primary": true,
"is_verified": true
}
'import requests
url = "https://{tenant_id}.hanko.io/admin/users/{id}/emails"
payload = {
"address": "jsmith@example.com",
"is_primary": True,
"is_verified": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({address: 'jsmith@example.com', is_primary: true, is_verified: true})
};
fetch('https://{tenant_id}.hanko.io/admin/users/{id}/emails', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{tenant_id}.hanko.io/admin/users/{id}/emails",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'address' => 'jsmith@example.com',
'is_primary' => true,
'is_verified' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://{tenant_id}.hanko.io/admin/users/{id}/emails"
payload := strings.NewReader("{\n \"address\": \"jsmith@example.com\",\n \"is_primary\": true,\n \"is_verified\": true\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{tenant_id}.hanko.io/admin/users/{id}/emails")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"address\": \"jsmith@example.com\",\n \"is_primary\": true,\n \"is_verified\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://{tenant_id}.hanko.io/admin/users/{id}/emails")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"address\": \"jsmith@example.com\",\n \"is_primary\": true,\n \"is_verified\": true\n}"
response = http.request(request)
puts response.read_body{
"id": "802df042-1ac2-496d-af81-6ace729ed055",
"address": "jsmith@example.com",
"is_verified": true,
"is_primary": true,
"created_at": "2023-11-07T05:31:56Z",
"updated_at": "2023-11-07T05:31:56Z"
}{
"code": 400,
"message": "Bad Request"
}{
"code": 404,
"message": "Not found"
}{
"code": 409,
"message": "Conflict"
}{
"code": 500,
"message": "Internal Server Error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your API key. Must only be used when using Hanko Cloud.
Path Parameters
UUID of the requested object
Body
application/json
Request Body for creating an email for a user
Response
Created
The ID of the email
Example:
"802df042-1ac2-496d-af81-6ace729ed055"
The email address
Indicated the email has been verified.
Indicates it's the primary email address.
Time of creation of the email
Time of last update of the email
Was this page helpful?
⌘I