Back

Send Email Verification With REST

  • 0
  • Self Hosted
  • Web
djcali
14 Dec, 2024, 00:56

I am using REST to create a user on the server side after receiving form data from the client. After the account is successfully created i wanted to send the verification email using REST also.

First I create the account like this:

``` const response = await fetch(${VITE_APPWRITE_ENDPOINT}/users, { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-Appwrite-Response-Format': '1.4.0', 'X-Appwrite-Project': VITE_APPWRITE_PROJECT_ID, 'X-Appwrite-Key': PRIVATE_API_KEY, }, body: JSON.stringify(payload)

TypeScript
        });

const json = await response.json();

TypeScript

The json will give me an object with the users account like $id and so on..

How can I use that with this?

```POST /v1/account/verification HTTP/1.1
Host: cloud.appwrite.io
Content-Type: application/json
X-Appwrite-Response-Format: 1.6.0
X-Appwrite-Project: <YOUR_PROJECT_ID>
X-Appwrite-Session: 
X-Appwrite-JWT: <YOUR_JWT>

{
  "url": "https://example.com"
}```

I don't see where i can pass the userID or email.

Thanks
TL;DR
Create the user account using REST, then obtain the userID. Use the userID in the body of the verification email request along with the "url" field.
Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more