/v1/auth/register
Register
Register
Create a new user account and receive an access token. The token is returned immediately so you can start making authenticated requests without a separate login call.
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Required | The user's display name. |
| string | Required | A valid email address. Must be unique across all accounts. | |
| password | string | Required | The account password. Must be at least 8 characters. |
| password_confirmation | string | Required | Must match the password field exactly. |
curl -X POST https://api.proxyhat.com/v1/auth/register \
-H "Content-Type: application/json" \
-H "Accept: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"password": "secretpassword",
"password_confirmation": "secretpassword"
}'
import requests
response = requests.post(
"https://api.proxyhat.com/v1/auth/register",
headers={
"Content-Type": "application/json",
"Accept": "application/json",
},
json={
"name": "John Doe",
"email": "john@example.com",
"password": "secretpassword",
"password_confirmation": "secretpassword",
},
)
data = response.json()
print(data["accessToken"])
const response = await fetch("https://api.proxyhat.com/v1/auth/register", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Accept": "application/json",
},
body: JSON.stringify({
name: "John Doe",
email: "john@example.com",
password: "secretpassword",
password_confirmation: "secretpassword",
}),
});
const data = await response.json();
console.log(data.accessToken);
payload := strings.NewReader(`{
"name": "John Doe",
"email": "john@example.com",
"password": "secretpassword",
"password_confirmation": "secretpassword"
}`)
req, _ := http.NewRequest("POST", "https://api.proxyhat.com/v1/auth/register", payload)
req.Header.Set("Content-Type", "application/json")
req.Header.Set("Accept", "application/json")
resp, err := http.DefaultClient.Do(req)
if err != nil {
log.Fatal(err)
}
defer resp.Body.Close()
var result map[string]interface{}
json.NewDecoder(resp.Body).Decode(&result)
fmt.Println(result["accessToken"])
{
"message": "User created",
"accessToken": "1|abc123...",
"tokenType": "Bearer"
}