# Mailjet Integration via LowCodeAPI

## Overview

Mailjet is an email service provider for sending marketing and transactional emails with powerful automation and segmentation features.

## Base Endpoint

```
https://api.lowcodeapi.com/mailjet/
```

## Authentication

LowCodeAPI handles authentication automatically. You only need to:

1. **Sign up** at https://www.mailjet.com/
2. **Connect your account** in LowCodeAPI dashboard
3. **Use your `api_token`** in all requests

The `api_token` is your LowCodeAPI authentication token. LowCodeAPI will automatically:
- Fetch your Mailjet API credentials from database
- Apply them to each request with proper authentication headers

**Auth Type**: `API Key` (Basic Authentication with API Key and Secret Key)

## API Categories

- Marketing Email
- Contacts
- Email (Send)
- Messages
- Campaigns
- Lists
- Segments

## Common Endpoints

### Category: Contacts

#### Create a Contact

**Method**: `POST` | **LowCodeAPI Path**: `/v4/contacts`

**Full URL**:
```
https://api.lowcodeapi.com/mailjet/v4/contacts?api_token={api_token}
```

**Description**: Add a new contact to your Mailjet account.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `Email` | string | Yes | Contact email address |
| `Name` | string | No | Contact name |
| `Properties` | object | No | Additional contact properties |
| `IsExcludedFromCampaigns` | boolean | No | Excludes from campaigns (default: false) |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/mailjet/v4/contacts?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "Email": "[email protected]",
    "Name": "John Doe",
    "IsExcludedFromCampaigns": false
  }'
```

**Official Documentation**: https://dev.mailjet.com/email/reference/contacts/contact-create/

---

#### Get Contact Details

**Method**: `GET` | **LowCodeAPI Path**: `/v4/contacts/contact_id`

**Full URL**:
```
https://api.lowcodeapi.com/mailjet/v4/contacts/contact_id?contact_id={contact_id}&api_token={api_token}
```

**Description**: Retrieve detailed information about a specific contact.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `contact_id` | string | Yes | The ID of the contact |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Example Request**:
```bash
# contact_id is numeric ID from contact list
curl -X GET "https://api.lowcodeapi.com/mailjet/v4/contacts/contact_id?contact_id=12345&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: https://dev.mailjet.com/email/reference/contacts/contact-by-id/

---

### Category: Email (Send)

#### Send Transactional Email

**Method**: `POST` | **LowCodeAPI Path**: `/v3.1/send`

**Full URL**:
```
https://api.lowcodeapi.com/mailjet/v3.1/send?api_token={api_token}
```

**Description**: Send a transactional email with full customization options.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `Messages` | array | Yes | Array of message objects |
| `SandboxMode` | boolean | No | Enable sandbox mode for testing |

**Message Object Fields**:

- `From`: Object with Email and Name
- `To`: Array of recipient objects
- `Cc`: Array of CC recipients
- `Bcc`: Array of BCC recipients
- `Subject`: Email subject line
- `TextPart`: Plain text content
- `HTMLPart`: HTML content
- `TemplateID`: Use a template instead of content
- `TemplateLanguage`: Enable template processing (default: true)
- `TemplateErrorReporting`: Email address for template errors
- `TemplateErrorDeliver`: Deliver template errors (default: false)
- `Variables`: Object with template variables

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/mailjet/v3.1/send?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "Messages": [
      {
        "From": {
          "Email": "[email protected]",
          "Name": "Sender Name"
        },
        "To": [
          {
            "Email": "[email protected]",
            "Name": "Recipient Name"
          }
        ],
        "Subject": "Your Order Has Shipped!",
        "HTMLPart": "<h3>Dear {{var:name}}</h3><p>Your order has shipped!</p>",
        "TextPart": "Dear {{var:name}}, Your order has shipped!",
        "Variables": {
          "name": "John"
        }
      }
    ]
  }'
```

**Official Documentation**: https://dev.mailjet.com/email/guides/send-api/

---

#### Send Using Template

**Method**: `POST` | **LowCodeAPI Path**: `/v3.1/send`

**Full URL**:
```
https://api.lowcodeapi.com/mailjet/v3.1/send?api_token={api_token}
```

**Description**: Send emails using a pre-configured template.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

Same as send above, but include `TemplateID` instead of HTML/Text content.

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/mailjet/v3.1/send?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "Messages": [
      {
        "From": {
          "Email": "[email protected]"
        },
        "To": [
          {
            "Email": "[email protected]"
          }
        ],
        "TemplateID": 123456,
        "TemplateLanguage": true,
        "Subject": "Welcome to Our Service",
        "Variables": {
          "name": "Jane",
          "confirmation_link": "https://example.com/confirm"
        }
      }
    ]
  }'
```

**Official Documentation**: https://dev.mailjet.com/email/guides/send-api/using-templates/

---

### Category: Messages

#### Get Message Details

**Method**: `GET` | **LowCodeAPI Path**: `/v4/messages/message_id`

**Full URL**:
```
https://api.lowcodeapi.com/mailjet/v4/messages/message_id?message_id={message_id}&api_token={api_token}
```

**Description**: Retrieve detailed information about a specific message.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `message_id` | string | Yes | The ID of the message |
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Example Request**:
```bash
# message_id from send response or message list
curl -X GET "https://api.lowcodeapi.com/mailjet/v4/messages/message_id?message_id=123456789&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: https://dev.mailjet.com/email/reference/messages/message-by-id/

---

### Category: Lists

#### Manage Contact Lists

**Method**: `GET` | **LowCodeAPI Path**: `/v4/rest/contactslist`

**Full URL**:
```
https://api.lowcodeapi.com/mailjet/v4/rest/contactslist?api_token={api_token}
```

**Description**: Retrieve all contact lists in your account.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |
| `Limit` | number | No | Number of results to return |
| `Offset` | number | No | Number of results to skip |

**Example Request**:
```bash
curl -X GET "https://api.lowcodeapi.com/mailjet/v4/rest/contactslist?Limit=50&api_token=YOUR_API_TOKEN"
```

**Official Documentation**: https://dev.mailjet.com/email/reference/contacts/contact-lists/

---

#### Create Contact List

**Method**: `POST` | **LowCodeAPI Path**: `/v4/rest/contactslist`

**Full URL**:
```
https://api.lowcodeapi.com/mailjet/v4/rest/contactslist?api_token={api_token}
```

**Description**: Create a new contact list.

**Query Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `api_token` | string | Yes | Your LowCodeAPI authentication token |

**Request Body Parameters**:

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| `Name` | string | Yes | List name |

**Example Request**:
```bash
curl -X POST "https://api.lowcodeapi.com/mailjet/v4/rest/contactslist?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "Name": "Monthly Newsletter Subscribers"
  }'
```

**Official Documentation**: https://dev.mailjet.com/email/reference/contacts/contact-list-create/

---

## Usage Examples

### Example 1: Send Simple Transactional Email

Send a basic email to a recipient.

```bash
# Send HTML and text email
curl -X POST "https://api.lowcodeapi.com/mailjet/v3.1/send?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "Messages": [
      {
        "From": {
          "Email": "[email protected]",
          "Name": "Example Company"
        },
        "To": [
          {
            "Email": "[email protected]",
            "Name": "Customer Name"
          }
        ],
        "Subject": "Your Order Confirmation",
        "HTMLPart": "<h1>Order Confirmed!</h1><p>Thank you for your purchase.</p>",
        "TextPart": "Order Confirmed! Thank you for your purchase."
      }
    ]
  }'
```

### Example 2: Send Using Template

Use stored templates for consistent branding.

```bash
# Send using template ID
# Variables populate {{var:variable}} placeholders in template
curl -X POST "https://api.lowcodeapi.com/mailjet/v3.1/send?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "Messages": [
      {
        "From": {
          "Email": "[email protected]"
        },
        "To": [
          {
            "Email": "[email protected]"
          }
        ],
        "TemplateID": 123456,
        "TemplateLanguage": true,
        "Subject": "Password Reset Request",
        "Variables": {
          "reset_link": "https://example.com/reset/token123",
          "expiry_hours": "24"
        }
      }
    ]
  }'
```

### Example 3: Manage Contacts

Add and manage contact information.

```bash
# Add new contact
curl -X POST "https://api.lowcodeapi.com/mailjet/v4/contacts?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "Email": "[email protected]",
    "Name": "New User",
    "Properties": {
      "city": "San Francisco",
      "country": "USA"
    }
  }'

# Get contact details
curl -X GET "https://api.lowcodeapi.com/mailjet/v4/contacts/contact_id?contact_id=CONTACT_ID&api_token=YOUR_API_TOKEN"
```

### Example 4: Manage Lists

Organize contacts into lists.

```bash
# Create new list
curl -X POST "https://api.lowcodeapi.com/mailjet/v4/rest/contactslist?api_token=YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "Name": "VIP Customers"
  }'

# Get all lists
curl -X GET "https://api.lowcodeapi.com/mailjet/v4/rest/contactslist?api_token=YOUR_API_TOKEN"
```

## Complete Endpoint Reference

For a complete list of all endpoints and their parameters, refer to:
- **OpenAPI Definition**: `https://backend.lowcodeapi.com/mailjet/definition`
- **Official Provider Documentation**: https://dev.mailjet.com/email/reference/

## Rate Limits & Best Practices

- Use templates for consistent branding and faster sends
- Batch recipients in single API calls when possible
- Monitor message status for delivery issues
- Segment contacts for targeted campaigns

## Error Handling

Standard HTTP status codes apply. Common errors include invalid email addresses, missing template IDs, or rate limiting.