How to Use the Temporary Email Service API
BLOG 2024-12-28

How to Use Temporary Email Service API

Temporary emails are a convenient tool for protecting privacy and avoiding spam. Our temporary email service offers simple and easy-to-use APIs that allow you to quickly generate and manage temporary emails, as well as handle email content. This tutorial provides a detailed step-by-step guide to each API, helping you get started efficiently.

Why Choose Our API?

Here is a detailed guide to using each API.

API Authentication

To ensure secure access to the API, all requests require proper authentication. This can be done using an API key and an authorization token in the request headers. Below is an example of how to include these headers in a request:

Example Request:

curl -X GET https://tempmail-so.p.rapidapi.com/domains \
--header 'x-rapidapi-key:{your-rapidapi-key}' \
--header 'Authorization: Bearer {your-token}'

Headers Explained:

Make sure to replace the placeholder values with your actual API key and token when making requests.

1. List Available Domains

Endpoint: GET /domains

Description: Retrieve a list of all available domains supported by the service.

Use Case: When creating an email, you need to select a domain. Free users have access to a limited number of domains, while paid users have access to a larger number of domains.

Sample Request:

curl -X GET https://tempmail-so.p.rapidapi.com/domains

Sample Response:

{
  "request-id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
  "message": "Success",
  "data": [
    {
      "domain": "<public domain>"
    },
    {
      "domain": "<alternate public domain>",
      "alternate": true
    },
    {
      "domain": "<custom domain>",
      "custom": true
    }
  ],
  "code": 0
}

2. Create an Inbox

Endpoint: POST /inboxes

Description: Create a new temporary email inbox.

Use Case: Generate a personalized temporary email by specifying a domain and an optional email prefix.

Request Parameters:

Sample Request:

curl -X POST https://tempmail-so.p.rapidapi.com/inboxes \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  -d name=hello123 \
  -d domain=mailnuo.com \
  -d lifespan=0

Sample Response:

{
  "request-id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
  "message": "Success",
  "data": {
    "id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"
  },
  "code": 0
}

Once successful, you will receive an inbox ID and the full email address for receiving emails.

3. List All Inboxes

Endpoint: GET /inboxes

Description: Retrieve all inboxes associated with your account.

Use Case: View all temporary emails you have created.

Sample Request:

curl -X GET https://tempmail-so.p.rapidapi.com/inboxes

Sample Response:

{
  "request-id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
  "message": "Success",
  "data": [
    {
      "created": 1700000000,
      "lifespan": 600,
      "id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
      "name": "<inbox address>",
      "permanent": false
    },
    {
      "created": 1700000000,
      "lifespan": 0,
      "id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
      "name": "<inbox address>",
      "permanent": true
    }
  ],
  "code": 0
}

4. Delete an Inbox

Endpoint: DELETE /inboxes/{inbox-id}

Description: Delete a specific inbox by ID.

Use Case: Remove an inbox when it is no longer needed.

Sample Request:

curl -X DELETE https://tempmail-so.p.rapidapi.com/inboxes/{indox-id}

Sample Response:

{
  "request-id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
  "message": "Success",
  "data": {
    "id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"
  },
  "code": 0
}

5. List Mails

Endpoint: GET /inboxes/{inbox-id}/mails

Description: Retrieve all emails received by a specific inbox.

Use Case: View all emails received in an inbox.

Sample Request:

curl -X GET https://tempmail-so.p.rapidapi.com/inboxes/{inbox-id}/mails

Sample Response:

{
  "request-id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
  "message": "Success",
  "data": [
    {
      "received": 1700000000,
      "from": "<sender address>",
      "read": false,
      "id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
      "subject": "<subject of mail>"
    }
  ],
  "code": 0
}

6. Retrieve Mail

Endpoint: GET /inboxes/{inbox-id}/mails/{mail-id}

Description: Retrieve detailed content of a specific email.

Use Case: View details such as the subject, sender, and body of an email.

Sample Request:

curl -X GET https://tempmail-so.p.rapidapi.com/inboxes/{inbox-id}/mails/{mail-id}

Sample Response:

{
  "request-id": "",
  "message": "",
  "data": {
    "textContent": "<text content of mail>",
    "forwarded": false,
    "htmlContent": "<html content of mail>",
    "received": 1700000000,
    "from": "<sender address>",
    "read": false,
    "id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
    "subject": "<mail subject>"
  },
  "code": 0
}

7. Delete Mail

Endpoint: DELETE /inboxes/{inbox-id}/mails/{mail-id}

Description: Delete a specific email.

Use Case: Remove an email when it is no longer needed.

Sample Request:

curl -X DELETE https://tempmail-so.p.rapidapi.com/inboxes/{inbox-id}/mails/{mail-id}

Sample Response:

{
    "request-id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF",
    "message": "Success",
    "data": {
        "id": "FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF"
    },
    "code": 0
}

Conclusion

With the above APIs, you can easily manage temporary email inboxes and their contents. Whether for protecting your privacy or completing temporary tasks, these APIs are highly practical. We are committed to providing a secure and fast email solution.

If you encounter any issues while using our service, please check out the complete documentation or contact our support team for assistance. Start your temporary email journey today!

You might also like

How Businesses Can Benefit from Temporary Email Services

How Businesses Can Benefit from Temporary Email Services

BLOG 2024-08-23
How to Choose the Right Temporary Email Service

How to Choose the Right Temporary Email Service

BLOG 2024-08-13
Protect Your Online Privacy: Benefits of Temporary Email Addresses

Protect Your Online Privacy: Benefits of Temporary Email Addresses

BLOG 2024-10-15
Stay Connected, Stay Private. Weekly updates Customer support Secure and privacy 99.99% uptime