---
# System prepended metadata

title: Email API

---

# Email API

## /v1/domain

Esta página descreve este recurso, que como o nome sugere, permite a manipulação das ações de email

<!-- ## GET

Use este recurso para listar os dominios do usuário

Parâmetros:

| nome      | descrição                                                         |
| --------- | ----------------------------------------------------------------- |
| offset    | Descarta *start* elementos da lista de dominios obtido. default 0 |
| limit     | Limita o número máximo de dominios a a ser retornado. default 10  |
| tenant    | Nome do tenant                                                    |
| owner_id  | Id do dono do dominio                                             |
| ~~order~~ | ~~Tipo de ordenação do resultado - desc/asc. default desc~~       |


Exemplo:

```
$ curl http://<endpoint>/v1/domain/\?offset\=1\&limit\=10\&tenant\=locaweb\&owner_id\=12341
{
    "results": [
        {
            "id": "123",
            "owner_id": "12341",
            "name": "pizza42.com.br",
            "max_email_accounts": "10",
            "default_quota": "5",
            "password_expiration": "120",
            "status": "enabled"
            "created_at": "2019-08-08T21:59:24.620877+00:00",
            "updated_at": "2019-08-14T13:58:49.218875+00:00",
        },
        {
            "id": "123",
            "owner_id": "12341",
            "created_at": "2019-08-08T21:59:24.620877+00:00",
            "updated_at": "2019-08-14T13:58:49.218875+00:00",
            "name": "pizzaleet.com.br",
            "max_email_accounts": "10",
            "default_quota": "5",
            "password_expiration": "120",
            "status": "disable"
        },
        {
            "id": "123",
            "owner_id": "12341",
            "created_at": "2019-08-08T21:59:24.620877+00:00",
            "updated_at": "2019-08-14T13:58:49.218875+00:00",
            "name": "pizzaleet.com.br",
            "max_email_accounts": "10",
            "default_quota": "5",
            "password_expiration": "120",
            "status": "waiting"
        },

    ],
    "previous": "",
    "limit": 10,
    "count": 3,
    "next": "",
    "start": 1
}

``` -->

## GET /v1/domain/:domain_name

Use este recurso para listar os dominios do usuário

Parâmetros:

| nome        | descrição       | obrigatório |
| ----------- | --------------- | ----------- |
| tenant      | Nome do tenant  | sim         |
| domain_name | Nome do dominio | sim         |



Exemplo:

```
$ curl http://<endpoint>/v1/domain/pizza43.com\?tenant\=locaweb
{
    
    "id": "123",
    "tenant": "locaweb",
    "owner_id": "12341",
    "domain_name": "pizza43.com.br",
    "mailboxes": {
        "10gb": 30,
        "15gb": 0,
        "30gb": 0,
        "50gb": 0
    },
    "created_at": "2019-08-08T21:59:24.620877+00:00",
    "updated_at": "2019-08-14T13:58:49.218875+00:00"
}

```


## POST /v1/domain

Cria um novo dominio 

Parametros:


| nome        | descrição          | obrigatório |
| ----------- | ------------------ | ----------- |
| tenant      | Nome do tenant     | sim         |
| domain_name | Nome do dominio    | sim         |
| owner_id    | Id do dono dominio | sim         |

Exemplo

```
$ curl -X POST -k -v https://localhost:5000/v1/domain -d "domain_name=pizza42.com.br" \
     -d "owner_id=3114" \
     -d "tenant=locaweb" \
```

O retorno do POST

```
> POST /v1/domains/ HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 173
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 173 out of 173 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 201 CREATED
< Content-Type: application/json
< Content-Length: 280
< Server: Werkzeug/0.15.4 Python/3.5.3
< Date: Wed, 19 Jun 2019 21:32:55 GMT
<
{
    "status": "waiting",
    "owner_id": "3114",
    "domain_name": "pizza42.com.br",
    "tenant": "locaweb",
    "created_at": "2019-08-08T21:59:24.620877+00:00",
    "updated_at": "2019-08-14T13:58:49.218875+00:00"
}

```


## PUT /v1/domain/:domain_name

Atualiza o status de um dominio 

Parametros:

| nome        | descrição              | obrigatório |
| ----------- | ---------------------- | ----------- |
| tenant      | Nome do tenant         | sim         |
| owner_id    | Id do dono dominio     | sim         |
| domain_name | Nome do dominio        | sim         |
| status      | Novo status do dominio | sim         |


Exemplo

```
$ curl -X PUT -v http://localhost:5000/v1/domain/pizza42.com.br\?tenant\=locaweb\&owner_id\=12341
    -d "status=active" \
```

Retorno:

```
* Connected to localhost (::1) port 5000 (#0)
> PUT /v1/domain/pizza42.com.br HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 34
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 34 out of 34 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Content-Type: application/json
< Content-Length: 282
< Server: Werkzeug/0.15.4 Python/3.5.3
< Date: Wed, 19 Jun 2019 21:48:38 GMT
<

{
    "status": "active",
    "owner_id": "3114",
    "domain_name": "pizza42.com.br",
    "tenant": "locaweb",
    "created_at": "2019-08-08T21:59:24.620877+00:00",
    "updated_at": "2019-08-14T13:58:49.218875+00:00"
}

```




## DELETE /v1/domain/:domain_name

Deleta um dominio se não tiver nenhum alias associado

Parametros:

| nome        | descrição              | obrigatório |
| ----------- | ---------------------- | ----------- |
| tenant      | Nome do tenant         | sim         |
| owner_id    | Id do dono dominio     | sim         |
| domain_name | Nome do dominio        | sim         |


Exemplo

```
$ curl -X DELETE -v http://localhost:5000/v1/domain/pizza42.com.br\?tenant\=locaweb\&owner_id\=12341
```

Retorno:

```
* Connected to localhost (::1) port 5000 (#0)
> DELETE /v1/domain/pizza42.com.br HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 34
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 34 out of 34 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 204 NO CONTENT
< Content-Type: application/json
< Content-Length: 282
< Server: Werkzeug/0.15.4 Python/3.5.3
< Date: Wed, 19 Jun 2019 21:48:38 GMT
<

```





## GET /v1/domain/:domain_name/alias

Use este recurso para listar os dominios alias do usuário

Parâmetros:

| nome        | descrição       | obrigatório |
| ----------- | --------------- | ----------- |
| tenant      | Nome do tenant  | sim         |
| domain_name | Nome do dominio | sim         |


spec/models/
Exemplo:

```
$ curl http://<endpoint>/v1/domain/pizza43.com/alias\?tenant\=locaweb
{
    
    "id": "123",
    "tenant": "locaweb",
    "owner_id": "12341",
    "domain_name": "pizza43.com.br",
    "alias": [
        {
            "domain_name": "alias1.com",
            "status": "active",
            "created_at": "2019-08-08T21:59:24.620877+00:00",
            "updated_at": "2019-08-14T13:58:49.218875+00:00"
        },
        {
            "domain_name": "alias2.com",
            "status": "active",
            "created_at": "2019-08-08T21:59:24.620877+00:00",
            "updated_at": "2019-08-14T13:58:49.218875+00:00"
        },
        {
            "domain_name": "alias3.com",
            "status": "active",
            "created_at": "2019-08-08T21:59:24.620877+00:00",
            "updated_at": "2019-08-14T13:58:49.218875+00:00"
        },
    ],
}

```





## POST /v1/domain/:domain_name/alias

Cria um novo dominio alias 

Parametros:


| nome        | descrição             | obrigatório |
| ----------- | --------------------- | ----------- |
| tenant      | Nome do tenant        | sim         |
| domain_name | Nome do dominio       | sim         |
| owner_id    | Id do dono dominio    | sim         |
| alias_name  | Nome do dominio alias | sim         |

Exemplo

```
$ curl -X POST -k -v https://localhost:5000/v1/domain/pizza42.com.br \
     -d "owner_id=3114" \
     -d "tenant=locaweb" \
```

O retorno do POST

```
> POST /v1/domains/ HTTP/1.1
> Host: localhost:5000
> User-Agent: curl/7.64.1
> Accept: */*
> Content-Length: 173
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 173 out of 173 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 201 CREATED
< Content-Type: application/json
< Content-Length: 280
< Server: Werkzeug/0.15.4 Python/3.5.3
< Date: Wed, 19 Jun 2019 21:32:55 GMT
<
{
    "status": "waiting",
    "owner_id": "3114",
    "domain_name": "pizza42.com.br",
    "tenant": "locaweb",
    "created_at": "2019-08-08T21:59:24.620877+00:00",
    "updated_at": "2019-08-14T13:58:49.218875+00:00"
}

```


## PUT

## POST


