Add dcoumentation for API (#18)
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
---
|
||||
title: Introduction
|
||||
description: "Fundamental concepts of Usend's API."
|
||||
---
|
||||
|
||||
## Base URL
|
||||
|
||||
Unsend's API is built on REST principles and is served over HTTPS. To ensure data privacy, unencrypted HTTP is not supported.
|
||||
|
||||
The Base URL for all API endpoints is:
|
||||
|
||||
```sh Terminal
|
||||
https://app.unsend.dev/api/
|
||||
```
|
||||
|
||||
## Authentication
|
||||
|
||||
Authentication to Usend's API is performed via the Authorization header with a Bearer token. To authenticate, you need to include the Authorization header with the word Bearer followed by your token in your API requests like so:
|
||||
|
||||
```sh Terminal
|
||||
Authorization: Bearer us_12345
|
||||
```
|
||||
|
||||
You can create a new token/API key under your Unsend [Developer Settings](https://app.unsend.dev/api-keys).
|
||||
|
@@ -106,6 +106,18 @@
|
||||
},
|
||||
"/v1/emails/{emailId}": {
|
||||
"get": {
|
||||
"parameters": [
|
||||
{
|
||||
"schema": {
|
||||
"type": "string",
|
||||
"minLength": 3,
|
||||
"example": "1212121"
|
||||
},
|
||||
"required": true,
|
||||
"name": "emailId",
|
||||
"in": "path"
|
||||
}
|
||||
],
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "Retrieve the user",
|
||||
|
35
apps/docs/get-started/nodejs.mdx
Normal file
35
apps/docs/get-started/nodejs.mdx
Normal file
@@ -0,0 +1,35 @@
|
||||
---
|
||||
title: NodeJS
|
||||
description: "Send your mail using unsend in NodeJS"
|
||||
---
|
||||
|
||||
## Prerequisites
|
||||
|
||||
- [Unsend API key](https://app.unsend.dev/api-keys)
|
||||
- [Verified domain](https://app.unsend.dev/domains)
|
||||
|
||||
## Code
|
||||
|
||||
```js server.ts
|
||||
const options = {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: "Bearer us_12345",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: {
|
||||
to: "jsmith@example.com",
|
||||
from: "jsmith@example.com",
|
||||
subject: "<string>",
|
||||
replyTo: "<string>",
|
||||
text: "<string>",
|
||||
html: "<string>",
|
||||
attachments: [{ filename: "<string>", content: "<string>" }],
|
||||
},
|
||||
};
|
||||
|
||||
fetch("https://app.unsend.dev/api/v1/emails", options)
|
||||
.then((response) => response.json())
|
||||
.then((response) => console.log(response))
|
||||
.catch((err) => console.error(err));
|
||||
```
|
@@ -30,4 +30,11 @@ Quicklinks to set up your account and get started
|
||||
>
|
||||
Learn how to use our API to send emails programmatically.
|
||||
</Card>
|
||||
<Card
|
||||
title="NodeJS"
|
||||
icon="node-js"
|
||||
href="/get-started/nodejs"
|
||||
>
|
||||
Learn how to use our API to send emails programmatically.
|
||||
</Card>
|
||||
</CardGroup>
|
||||
|
@@ -47,11 +47,12 @@
|
||||
{
|
||||
"group": "Get Started",
|
||||
"pages": [
|
||||
"introduction"
|
||||
"introduction",
|
||||
"get-started/nodejs"
|
||||
]
|
||||
},
|
||||
{
|
||||
"group": "API Documentation",
|
||||
"group": "API Reference",
|
||||
"pages": [
|
||||
"api-reference/introduction"
|
||||
]
|
||||
@@ -76,7 +77,7 @@
|
||||
"method": "bearer"
|
||||
},
|
||||
"playground": {
|
||||
"mode": "simple"
|
||||
"mode": "show"
|
||||
}
|
||||
},
|
||||
"footerSocials": {
|
||||
|
Reference in New Issue
Block a user