# Introduction

The Malomo API is organized around [REST](https://en.wikipedia.org/wiki/Representational_state_transfer). Our API has predictable resource oriented URLs, accepts [form-encoded](https://en.wikipedia.org/wiki/POST_\(HTTP\)#Use_for_submitting_web_forms) and [JSON-encoded](https://en.wikipedia.org/wiki/JSON) request bodies, returns [JSON-encoded](https://en.wikipedia.org/wiki/JSON) responses, and uses standard HTTP response codes, authentication and verbs.


# Authentication

Malomo authenticates your API requests using your account's API keys. If you do not include your key when making an API request, or use one that is incorrect or outdated, Malomo returns an error.

There are two types of API keys: *publishable* and *secret*.

* **Publishable** API keys are meant solely to identify your account with Malomo, they aren't secret. In other words, they can safely be published in places like your Malomo.js JavaScript code or in an Android or iPhone app. Publishable keys only have the ability to retrieve shipment information.
* **Secret** API keys should be kept confidential and only stored on your own servers. Your account's secret API key can perform any API request to Malomo without restriction. Be sure to keep this key secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, an so-forth.

Authentication to the API is performed by providing your API key as a bearer token in the **`Authorization`** HTTP header.

```
curl https://api.gomalomo.com/orders/1323fa24-f252-4f97-9960-a36fee7c3a6a \
  -H "Authorization: Bearer sk_452e3bab2f8c1f7cf03de018855fdf7e"
  -H "Accept: application/vnd.malomo+json; version=2"
```

All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.


# Versioning

API versioning allows Malomo to continuously evolve the platform while offering third-party developers a predictable path for feature upgrades and deprecations.

### Version Header

You can specify a version using the `Accept` header on each request. The current API version is `application/vnd.malomo+json; version=2`.

#### Example

```
curl https://api.gomalomo.com/orders/1323fa24-f252-4f97-9960-a36fee7c3a6a \
  -H "Authorization: Bearer sk_452e3bab2f8c1f7cf03de018855fdf7e"
  -H "Accept: application/vnd.malomo+json; version=2"
```


# Errors

Malomo uses conventional HTTP response codes to indicate success or failure of an API request. In general: Codes in the `2xx` range indicate success. Codes in the `4xx` range indicates that a request failed with the information provided. Codes in the `5xx` range indicate an error with Malomo's servers.

| HTTP STATUS CODE                   |                                           |
| ---------------------------------- | ----------------------------------------- |
| 200 - OK                           | Everything worked as expected             |
| 400 - Bad Request                  | The request couldn't be completed         |
| 401 - Unauthorized                 | No valid API key was provided             |
| 404 - Not Found                    | The requested resource could not be found |
| 500, 502, 503, 504 - Server Errors | We screwed up. Sorry!                     |

#### `400`, `401`, `404` and `5xx` Response Format

| ATTRIBUTE    |                                                                 |
| ------------ | --------------------------------------------------------------- |
| `code`       | The type of error returned                                      |
| `message`    | A human-readable message providing more details about the error |
| `request_id` | Unique identifier for a specific request                        |
| `status`     | HTTP status code                                                |


# Webhooks

Malomo can send webhook events that notify your application any time an event happens on your account. This can be useful for events -- like shipment updates -- that are not triggered by a direct API call. Webhooks can also be useful for services that are not directly responsible for making an API request but still need to know the response from that request.

All webhook events are sent with JSON-encoded request bodies.

Webhooks are created using our API. Please see the [webhooks section](/resources/webhook) for information specific to managing webhooks.

#### Settings

A webhook is made up of three parts. A destination URL that webhook events will be sent to, a topic defining what type of events to send and an optional secret that can be used as a key to verify the authenticity of a request. A webhook will only receieve events for the topic it is subscribed to. You must register a webhook for each topic you want to subscribe to.

#### Receiving a Notification

Webhook events are sent to the URL provided when creating a webhook. The endpoint should accept the request and return a `2xx` status code. If a status code other than `2xx` is returned the request will be considered unsuccessful and another request will be scheduled using an exponential backoff algorithm.

We will attempt to deliver an event up to 10 times over a 24 hour period. A request will timeout and be considered unsuccessful if it is not processed within 10 seconds. As a best practice it is recommended to perform any processing of the event asynchronously (e.g. a background job) and return a response as quickly as possible.

#### Delivery Headers

Webhook events will be sent as HTTP `POST` requests to your webhook's URL. Each event will contain the following headers.

| Header                  | Description                                                                                                                                                                                                     |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Malomo-Attempt-Number` | Current attempt number for a webhook event                                                                                                                                                                      |
| `Malomo-Topic`          | Name of the topic that triggered the webhook attempt                                                                                                                                                            |
| `Malomo-Webhook-Id`     | Unique identifier of the webhook used to send events                                                                                                                                                            |
| `Malomo-Signature`      | <p>Signature that can be used to verify the authenticity of a request. </p><p>This header will only be provided if the webhook contains a <br>secret. Please see the verification section for more details.</p> |
| `User-Agent`            | Set to `Malomo-Webhook-Agent/2.0`                                                                                                                                                                               |

#### Verification

Malomo can optionally sign the event requests it sends to your webhook URL's. When a webhook is configured with a secret we will include an `Malomo-Signature` header on each request.

The header will contain a string that is a cryptographically signed signature of the response body. The signature is computed using the HMAC-SHA256 algorithm with the webhook secret as the key.

If the webhook does not have a secret then the `Malomo-Signature` header will not be sent as part of the request.

#### Topics

A topic specifies the type of event sent to a webhook. Each webhook can listen to only one topic. If you need to listen for multiple topics you can create a webhook for each topic.

Possible topics include.

* `customers:created`
* `customers:deleted`
* `customers:updated`
* `events:created`
* `orders:created`
* `orders:deleted`
* `orders:updated`

#### Webhook Body

The webhook body is identical to the response of the resource's REST endpoints. For example, a webhook event for the `orders:created` topic would correspond to the [Order](/resources/order) resource. Please see the resources section for examples of the response body for each resource type.


# Supported Carriers

Carriers support by Malomo

When registering a shipment with Malomo you can provide the `code` value as a carrier.

🔒 - Carrier requires extra credentials in order to enable shipment tracking

| Carrier                              | Code                   |
| ------------------------------------ | ---------------------- |
| APC Postal Logistics                 | `apc_postal_logistics` |
| Asendia USA 🔒                       | `asendia_usa`          |
| Australia Post 🔒                    | `australia_post`       |
| AxleHire 🔒                          | `axlehire`             |
| Better Trucks 🔒                     | `better_trucks`        |
| Canada Post                          | `canada_post`          |
| Canpar                               | `canpar`               |
| CDL 🔒                               | `cdl`                  |
| Chronopost                           | `chronopost`           |
| Cloudsort 🔒                         | `cloudsort`            |
| Courier Express                      | `courier_express`      |
| CouriersPlease 🔒                    | `couriersplease`       |
| DAI Post                             | `dai_post`             |
| Deliver-It                           | `deliverit`            |
| Deutsche Post                        | `deutsche_post`        |
| Deutsche Post UK                     | `deutsche_post_uk`     |
| DHL eCommerce                        | `dhl_ecommerce`        |
| DHL eCommerce Asia                   | `dhl_ecommerce_asia`   |
| DHL Express                          | `dhl_express`          |
| DHL Paket                            | `dhl_paket`            |
| DPD                                  | `dpd`                  |
| DPD UK                               | `dpd_uk`               |
| ePost Global (formerly RR Donnelley) | `epost_global`         |
| Evri (formerly Hermes) 🔒            | `evri`                 |
| FedEx                                | `fedex`                |
| FedEx Cross Border 🔒                | `fedex_cross_border`   |
| FedEx MailView                       | `fedex_mailview`       |
| FedEx SameDay City                   | `fedex_sameday_city`   |
| FedEx Smart Post                     | `fedex_smart_post`     |
| FirstMile                            | `firstmile`            |
| GLS (formerly GSO)                   | `gso`                  |
| Hailify                              | `hailify`              |
| Interlink Express                    | `interlink_express`    |
| Japan Post                           | `japan_post`           |
| La Poste                             | `la_poste`             |
| LaserShip 🔒                         | `lasership`            |
| Loomis Express                       | `loomis_express`       |
| LSO                                  | `lso`                  |
| Newgistics                           | `newgistics`           |
| OnTrac 🔒                            | `on_trac`              |
| Optima                               | `optima`               |
| OSM 🔒                               | `osm`                  |
| Parcelforce                          | `parcelforce`          |
| PARCLL                               | `parcll`               |
| Passport                             | `passport`             |
| PostNL                               | postnl                 |
| Purolator                            | `purolator`            |
| Royal Mail                           | `royal_mail`           |
| RR Donnelley                         | `rr_donnelley`         |
| SEKO OmniParcel                      | `omni_parcel`          |
| Sendle 🔒                            | `sendle`               |
| SF Express 🔒                        | `sf_express`           |
| SmartKargo                           | `smartkargo`           |
| Sonic                                | `sonic`                |
| Spee-Dee                             | `speedee`              |
| Swyft 🔒                             | `swyft`                |
| TForce Logistics                     | `tforce`               |
| Toll                                 | `toll`                 |
| UDS                                  | `uds`                  |
| UPS                                  | `ups`                  |
| UPS i-Parcel                         | `ups_iparcel`          |
| UPS Mail Innovations                 | `ups_mail_innovations` |
| USPS                                 | `usps`                 |
| Veho 🔒                              | `veho`                 |
| Yamato                               | `yamato`               |
| Yanwen                               | `yanwen`               |


# Order

![](https://2604198532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ljb6kldSmEV1tpebdRd%2F-LruC2aTm-ZMy8Rc17ip%2F-LruCWuJfbnVY5ZGE_FD%2FResource%20Map%20-%20Order.png?alt=media\&token=5768aed8-1e8c-463a-bb3c-6bda5abde0d3)

### Order Properties

| Field          | Description                                                                                                                                                      |
| -------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `alternate_id` | Custom unique identifier that can be used to lookup an order. This typically is the primary key of the order located in a system outside of the Malomo Platform. |
| `created_at`   | When an `Order` was created on the Malomo Platform.                                                                                                              |
| `customer`     | `Customer` an `Order` belongs to.                                                                                                                                |
| `email`        | Email address that should be used for communication about an order. This email address may be different from the `Customer` email address.                       |
| `id`           | Unique identifier for an `Order`.                                                                                                                                |
| `meta`         | Additional, arbitrary information attached to an `Order`. These can be useful for storing additional information about an order in a structured format.          |
| `number`       | A number identifying an order placed by a customer.                                                                                                              |
| `shipments`    | Shipments associated with an `Order`.                                                                                                                            |
| `updated_at`   | When an `Order` was last updated.                                                                                                                                |

## Create an Order

<mark style="color:green;">`POST`</mark> `https://api.gomalomo.com/orders`

#### Request Body

| Name          | Type   | Description                                                                        |
| ------------- | ------ | ---------------------------------------------------------------------------------- |
| alternate\_id | string | Custom unique identifier that can be used to lookup an `Order`.                    |
| customer      | object | `Customer` object used to assign a `Customer` to an `Order`.                       |
| email         | string | Email address to be used for communication with a customer about a specific order. |
| meta          | object | Additional, arbitrary information attached to an `Order`.                          |
| number        | string | A number identifying an order placed by a customer.                                |
| shipments     | array  | An array of `Shipment` objects containing both a `carrier` and `tracking_code`.    |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "alternate_id": "450789469",
  "created_at": "2019-01-30T13:30:00Z",
  "customer": {
    "email": "john@example.com",
    "first_name": "John",
    "last_name": "Smith"
  },
  "email": "john@example.com",
  "id": "58f3d13f-2979-462b-92f8-4b85c6ee6abe",
  "meta": {
    "shopify_order": {
      "order_id": 450789469
    }
  }
  "number": "1000",
  "shipments": [
    {
      "alternative_carrier_identifier": null,
      "carrier": "usps",
      "carrier_name": "USPS",
      "carrier_service": "First-Class Package Service",
      "carrier_url": "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=9400000000000000000000"
      "container_type": null,
      "delivered_at": "2019-01-30T13:30:00",
      "destination": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "estimated_delivered_at": "2019-01-30T13:30:00",
      "estimated_local_delivered_at": null,
      "estimated_local_delivered_on": null,
      "guaranteed_delivered_at": null,
      "id": "ef1e8884-5188-457a-950a-6247c5e59e91",
      "initial_delivery_attempted_at": "2019-01-30T13:30:00",
      "is_return": false,
      "origin": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "original_estimated_delivered_at": "2019-01-30T13:30:00",
      "scan_events": [
        {
          "carrier_code": "GX",
          "description": "Shipping Label Created, USPS Awaiting Item",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN",
          },
          "message": "January 28 1:23 pm Shipping Label Created, USPS Awaiting Item in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T13:23:00",
          "source": "USPS",
          "status": "pre_transit",
          "status_detail": "label_created"
        },
        {
          "carrier_code": "OA",
          "description": "Accepted at USPS Origin Facility",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 28 8:29 pm Accepted at USPS Origin Facility in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T20:29:00",
          "source": "USPS",
          "status": "in_transit",
          "status_detail": "received_at_origin_facility"
        },
        {
          "carrier_code": "OF",
          "description": "Out for Delivery",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 9:16 am Out for Delivery in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T09:16:00",
          "source": "USPS",
          "status": "out_for_delivery",
          "status_detail": "out_for_delivery"
        },
        {
          "carrier_code": "01",
          "description": "Delivered, In/At Mailbox",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 1:30 pm Delivered, In/At Mailbox in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T13:30:00",
          "source": "USPS",
          "status": "delivered",
          "status_detail": "arrived_at_destination"
        }
      ],
      "signed_by": "null",
      "status": "delivered",
      "tracking_code": "9400000000000000000000",
      "weight": null
    }
  ],
  "updated_at": "2019-01-30T13:30:00Z"
}
```

{% endtab %}
{% endtabs %}

## Retrieve an Order

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/orders/:id`

#### Path Parameters

| Name | Type   | Description                            |
| ---- | ------ | -------------------------------------- |
| id   | string | Unique identifier of the desired order |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "alternate_id": "450789469",
  "created_at": "2019-01-30T13:30:00Z",
  "customer": {
    "email": "john@example.com",
    "first_name": "John",
    "last_name": "Smith"
  },
  "email": "john@example.com",
  "id": "58f3d13f-2979-462b-92f8-4b85c6ee6abe",
  "meta": {
    "shopify_order": {
      "order_id": 450789469
    }
  }
  "number": "1000",
  "shipments": [
    {
      "alternative_carrier_identifier": null,
      "carrier": "usps",
      "carrier_name": "USPS",
      "carrier_service": "First-Class Package Service",
      "carrier_url": "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=9400000000000000000000"
      "container_type": null,
      "delivered_at": "2019-01-30T13:30:00",
      "destination": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "estimated_delivered_at": "2019-01-30T13:30:00",
      "estimated_local_delivered_at": null,
      "estimated_local_delivered_on": null,
      "guaranteed_delivered_at": null,
      "id": "ef1e8884-5188-457a-950a-6247c5e59e91",
      "initial_delivery_attempted_at": "2019-01-30T13:30:00",
      "is_return": false,
      "origin": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "original_estimated_delivered_at": "2019-01-30T13:30:00",
      "scan_events": [
        {
          "carrier_code": "GX",
          "description": "Shipping Label Created, USPS Awaiting Item",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN",
          },
          "message": "January 28 1:23 pm Shipping Label Created, USPS Awaiting Item in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T13:23:00",
          "source": "USPS",
          "status": "pre_transit",
          "status_detail": "label_created"
        },
        {
          "carrier_code": "OA",
          "description": "Accepted at USPS Origin Facility",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 28 8:29 pm Accepted at USPS Origin Facility in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T20:29:00",
          "source": "USPS",
          "status": "in_transit",
          "status_detail": "received_at_origin_facility"
        },
        {
          "carrier_code": "OF",
          "description": "Out for Delivery",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 9:16 am Out for Delivery in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T09:16:00",
          "source": "USPS",
          "status": "out_for_delivery",
          "status_detail": "out_for_delivery"
        },
        {
          "carrier_code": "01",
          "description": "Delivered, In/At Mailbox",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 1:30 pm Delivered, In/At Mailbox in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T13:30:00",
          "source": "USPS",
          "status": "delivered",
          "status_detail": "arrived_at_destination"
        }
      ],
      "signed_by": "null",
      "status": "delivered",
      "tracking_code": "9400000000000000000000",
      "weight": null
    }
  ],
  "updated_at": "2019-01-30T13:30:00Z"
}
```

{% endtab %}
{% endtabs %}

## Retrieve an Order by Alternate Id

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/orders/?alternate_id=:alternate_id`

#### Query Parameters

| Name          | Type   | Description                                                      |
| ------------- | ------ | ---------------------------------------------------------------- |
| alternate\_id | string | Custom, unique identifier that can be used to lookup an `Order`. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "alternate_id": "450789469",
  "created_at": "2019-01-30T13:30:00Z",
  "customer": {
    "email": "john@example.com",
    "first_name": "John",
    "last_name": "Smith"
  },
  "email": "john@example.com",
  "id": "58f3d13f-2979-462b-92f8-4b85c6ee6abe",
  "meta": {
    "shopify_order": {
      "order_id": 450789469
    }
  }
  "number": "1000",
  "shipments": [
    {
      "alternative_carrier_identifier": null,
      "carrier": "usps",
      "carrier_name": "USPS",
      "carrier_service": "First-Class Package Service",
      "carrier_url": "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=9400000000000000000000"
      "container_type": null,
      "delivered_at": "2019-01-30T13:30:00",
      "destination": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "estimated_delivered_at": "2019-01-30T13:30:00",
      "estimated_local_delivered_at": null,
      "estimated_local_delivered_on": null,
      "guaranteed_delivered_at": null,
      "id": "ef1e8884-5188-457a-950a-6247c5e59e91",
      "initial_delivery_attempted_at": "2019-01-30T13:30:00",
      "is_return": false,
      "origin": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "original_estimated_delivered_at": "2019-01-30T13:30:00",
      "scan_events": [
        {
          "carrier_code": "GX",
          "description": "Shipping Label Created, USPS Awaiting Item",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN",
          },
          "message": "January 28 1:23 pm Shipping Label Created, USPS Awaiting Item in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T13:23:00",
          "source": "USPS",
          "status": "pre_transit",
          "status_detail": "label_created"
        },
        {
          "carrier_code": "OA",
          "description": "Accepted at USPS Origin Facility",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 28 8:29 pm Accepted at USPS Origin Facility in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T20:29:00",
          "source": "USPS",
          "status": "in_transit",
          "status_detail": "received_at_origin_facility"
        },
        {
          "carrier_code": "OF",
          "description": "Out for Delivery",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 9:16 am Out for Delivery in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T09:16:00",
          "source": "USPS",
          "status": "out_for_delivery",
          "status_detail": "out_for_delivery"
        },
        {
          "carrier_code": "01",
          "description": "Delivered, In/At Mailbox",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 1:30 pm Delivered, In/At Mailbox in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T13:30:00",
          "source": "USPS",
          "status": "delivered",
          "status_detail": "arrived_at_destination"
        }
      ],
      "signed_by": "null",
      "status": "delivered",
      "tracking_code": "9400000000000000000000",
      "weight": null
    }
  ],
  "updated_at": "2019-01-30T13:30:00Z"
}
```

{% endtab %}
{% endtabs %}

## Retrieve an Order by Tracking Code

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/orders/?tracking_code=:tracking_code`

#### Query Parameters

| Name           | Type   | Description                                          |
| -------------- | ------ | ---------------------------------------------------- |
| tracking\_code | string | Code provided by the carrier to tracking a shipment. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "alternate_id": "450789469",
  "created_at": "2019-01-30T13:30:00Z",
  "customer": {
    "email": "john@example.com",
    "first_name": "John",
    "last_name": "Smith"
  },
  "email": "john@example.com",
  "id": "58f3d13f-2979-462b-92f8-4b85c6ee6abe",
  "meta": {
    "shopify_order": {
      "order_id": 450789469
    }
  }
  "number": "1000",
  "shipments": [
    {
      "alternative_carrier_identifier": null,
      "carrier": "usps",
      "carrier_name": "USPS",
      "carrier_service": "First-Class Package Service",
      "carrier_url": "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=9400000000000000000000"
      "container_type": null,
      "delivered_at": "2019-01-30T13:30:00",
      "destination": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "estimated_delivered_at": "2019-01-30T13:30:00",
      "estimated_local_delivered_at": null,
      "estimated_local_delivered_on": null,
      "guaranteed_delivered_at": null,
      "id": "ef1e8884-5188-457a-950a-6247c5e59e91",
      "initial_delivery_attempted_at": "2019-01-30T13:30:00",
      "is_return": false,
      "origin": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "original_estimated_delivered_at": "2019-01-30T13:30:00",
      "scan_events": [
        {
          "carrier_code": "GX",
          "description": "Shipping Label Created, USPS Awaiting Item",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN",
          },
          "message": "January 28 1:23 pm Shipping Label Created, USPS Awaiting Item in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T13:23:00",
          "source": "USPS",
          "status": "pre_transit",
          "status_detail": "label_created"
        },
        {
          "carrier_code": "OA",
          "description": "Accepted at USPS Origin Facility",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 28 8:29 pm Accepted at USPS Origin Facility in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T20:29:00",
          "source": "USPS",
          "status": "in_transit",
          "status_detail": "received_at_origin_facility"
        },
        {
          "carrier_code": "OF",
          "description": "Out for Delivery",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 9:16 am Out for Delivery in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T09:16:00",
          "source": "USPS",
          "status": "out_for_delivery",
          "status_detail": "out_for_delivery"
        },
        {
          "carrier_code": "01",
          "description": "Delivered, In/At Mailbox",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 1:30 pm Delivered, In/At Mailbox in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T13:30:00",
          "source": "USPS",
          "status": "delivered",
          "status_detail": "arrived_at_destination"
        }
      ],
      "signed_by": "null",
      "status": "delivered",
      "tracking_code": "9400000000000000000000",
      "weight": null
    }
  ],
  "updated_at": "2019-01-30T13:30:00Z"
}
```

{% endtab %}
{% endtabs %}

## Retrieve an Order by Order Number and Customer Email Address

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/orders/?number=:number&customer_email=:customer_email`

#### Query Parameters

| Name            | Type   | Description                                                              |
| --------------- | ------ | ------------------------------------------------------------------------ |
| number          | string | Number of the `Order` to retrieve.                                       |
| customer\_email | string | Email address of the `Customer` associated with the `Order` to retrieve. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "alternate_id": "450789469",
  "created_at": "2019-01-30T13:30:00Z",
  "customer": {
    "email": "john@example.com",
    "first_name": "John",
    "last_name": "Smith"
  },
  "email": "john@example.com",
  "id": "58f3d13f-2979-462b-92f8-4b85c6ee6abe",
  "meta": {
    "shopify_order": {
      "order_id": 450789469
    }
  }
  "number": "1000",
  "shipments": [
    {
      "alternative_carrier_identifier": null,
      "carrier": "usps",
      "carrier_name": "USPS",
      "carrier_service": "First-Class Package Service",
      "carrier_url": "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=9400000000000000000000"
      "container_type": null,
      "delivered_at": "2019-01-30T13:30:00",
      "destination": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "estimated_delivered_at": "2019-01-30T13:30:00",
      "estimated_local_delivered_at": null,
      "estimated_local_delivered_on": null,
      "guaranteed_delivered_at": null,
      "id": "ef1e8884-5188-457a-950a-6247c5e59e91",
      "initial_delivery_attempted_at": "2019-01-30T13:30:00",
      "is_return": false,
      "origin": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "original_estimated_delivered_at": "2019-01-30T13:30:00",
      "scan_events": [
        {
          "carrier_code": "GX",
          "description": "Shipping Label Created, USPS Awaiting Item",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN",
          },
          "message": "January 28 1:23 pm Shipping Label Created, USPS Awaiting Item in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T13:23:00",
          "source": "USPS",
          "status": "pre_transit",
          "status_detail": "label_created"
        },
        {
          "carrier_code": "OA",
          "description": "Accepted at USPS Origin Facility",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 28 8:29 pm Accepted at USPS Origin Facility in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T20:29:00",
          "source": "USPS",
          "status": "in_transit",
          "status_detail": "received_at_origin_facility"
        },
        {
          "carrier_code": "OF",
          "description": "Out for Delivery",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 9:16 am Out for Delivery in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T09:16:00",
          "source": "USPS",
          "status": "out_for_delivery",
          "status_detail": "out_for_delivery"
        },
        {
          "carrier_code": "01",
          "description": "Delivered, In/At Mailbox",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 1:30 pm Delivered, In/At Mailbox in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T13:30:00",
          "source": "USPS",
          "status": "delivered",
          "status_detail": "arrived_at_destination"
        }
      ],
      "signed_by": "null",
      "status": "delivered",
      "tracking_code": "9400000000000000000000",
      "weight": null
    }
  ],
  "updated_at": "2019-01-30T13:30:00Z"
}
```

{% endtab %}
{% endtabs %}

## Retrieve a List of Orders

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/orders`

#### Query Parameters

| Name | Type   | Description                            |
| ---- | ------ | -------------------------------------- |
| prev | string | Retrieve orders before a given cursor. |
| next | string | Retrieve orders after a given cursor.  |

{% tabs %}
{% tab title="200 " %}

```javascript
[
  {
    "alternate_id": "450789469",
    "created_at": "2019-01-30T13:30:00Z",
    "customer": {
      "email": "john@example.com",
      "first_name": "John",
      "last_name": "Smith"
    },
    "email": "john@example.com",
    "id": "58f3d13f-2979-462b-92f8-4b85c6ee6abe",
    "meta": {
      "shopify_order": {
        "order_id": 450789469
      }
    }
    "number": "1000",
    "shipments": [
      {
        "alternative_carrier_identifier": null,
        "carrier": "usps",
        "carrier_name": "USPS",
        "carrier_service": "First-Class Package Service",
        "carrier_url": "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=9400000000000000000000"
        "container_type": null,
        "delivered_at": "2019-01-30T13:30:00",
        "destination": {
          "city": "INDIANAPOLIS",
          "country": null,
          "postal_code": "46203",
          "state": "IN"
        },
        "estimated_delivered_at": "2019-01-30T13:30:00",
        "estimated_local_delivered_at": null,
        "estimated_local_delivered_on": null,
        "guaranteed_delivered_at": null,
        "id": "ef1e8884-5188-457a-950a-6247c5e59e91",
        "initial_delivery_attempted_at": "2019-01-30T13:30:00",
        "is_return": false,
        "origin": {
          "city": "INDIANAPOLIS",
          "country": null,
          "postal_code": "46203",
          "state": "IN"
        },
        "original_estimated_delivered_at": "2019-01-30T13:30:00",
        "scan_events": [
          {
            "carrier_code": "GX",
            "description": "Shipping Label Created, USPS Awaiting Item",
            "location": {
              "city": "INDIANAPOLIS",
              "country": null,
              "postal_code": "46203",
              "state": "IN",
            },
            "message": "January 28 1:23 pm Shipping Label Created, USPS Awaiting Item in INDIANAPOLIS, IN",
            "scanned_at": "2019-01-28T13:23:00",
            "source": "USPS",
            "status": "pre_transit",
            "status_detail": "label_created"
          },
          {
            "carrier_code": "OA",
            "description": "Accepted at USPS Origin Facility",
            "location": {
              "city": "INDIANAPOLIS",
              "country": null,
              "postal_code": "46203",
              "state": "IN"
            },
            "message": "January 28 8:29 pm Accepted at USPS Origin Facility in INDIANAPOLIS, IN",
            "scanned_at": "2019-01-28T20:29:00",
            "source": "USPS",
            "status": "in_transit",
            "status_detail": "received_at_origin_facility"
          },
          {
            "carrier_code": "OF",
            "description": "Out for Delivery",
            "location": {
              "city": "INDIANAPOLIS",
              "country": null,
              "postal_code": "46203",
              "state": "IN"
            },
            "message": "January 30 9:16 am Out for Delivery in INDIANAPOLIS, IN",
            "scanned_at": "2019-01-30T09:16:00",
            "source": "USPS",
            "status": "out_for_delivery",
            "status_detail": "out_for_delivery"
          },
          {
            "carrier_code": "01",
            "description": "Delivered, In/At Mailbox",
            "location": {
              "city": "INDIANAPOLIS",
              "country": null,
              "postal_code": "46203",
              "state": "IN"
            },
            "message": "January 30 1:30 pm Delivered, In/At Mailbox in INDIANAPOLIS, IN",
            "scanned_at": "2019-01-30T13:30:00",
            "source": "USPS",
            "status": "delivered",
            "status_detail": "arrived_at_destination"
          }
        ],
        "signed_by": "null",
        "status": "delivered",
        "tracking_code": "9400000000000000000000",
        "weight": null
      }
    ],
    "updated_at": "2019-01-30T13:30:00Z"
  }
]
```

{% endtab %}
{% endtabs %}

## Update an Order

<mark style="color:orange;">`PUT`</mark> `https://api.gomalomo.com/orders/:id`

#### Path Parameters

| Name | Type   | Description                              |
| ---- | ------ | ---------------------------------------- |
| id   | string | Unique identifier of the order to update |

#### Request Body

| Name      | Type   | Description                                                                                                                                                                                                                                                                                                        |
| --------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| customer  | object | `Customer` object used to assign a `Customer` to an `Order`. If a value of `null` is provided the customer will be removed from the order.                                                                                                                                                                         |
| email     | string | Email address to be used for communication with a customer about a specific order.                                                                                                                                                                                                                                 |
| meta      | object | Additional, arbitrary information attached to an `Order`.                                                                                                                                                                                                                                                          |
| shipments | array  | An array of objects containing both a `carrier` and `tracking_code`. Note that this must be a complete list of `carrier` and `tracking_code` combinations for an `Order`. If a `carrier` and `tracking_code` that currently exist on an `Order` are not supplied that `Shipment` will be removed from the `Order`. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "alternate_id": "450789469",
  "created_at": "2019-01-30T13:30:00Z",
  "customer": {
    "email": "john@example.com",
    "first_name": "John",
    "last_name": "Smith"
  },
  "email": "john@example.com",
  "id": "58f3d13f-2979-462b-92f8-4b85c6ee6abe",
  "meta": {
    "shopify_order": {
      "order_id": 450789469
    }
  }
  "number": "1000",
  "shipments": [
    {
      "alternative_carrier_identifier": null,
      "carrier": "usps",
      "carrier_name": "USPS",
      "carrier_service": "First-Class Package Service",
      "carrier_url": "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=9400000000000000000000"
      "container_type": null,
      "delivered_at": "2019-01-30T13:30:00",
      "destination": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "estimated_delivered_at": "2019-01-30T13:30:00",
      "estimated_local_delivered_at": null,
      "estimated_local_delivered_on": null,
      "guaranteed_delivered_at": null,
      "id": "ef1e8884-5188-457a-950a-6247c5e59e91",
      "initial_delivery_attempted_at": "2019-01-30T13:30:00",
      "is_return": false,
      "origin": {
        "city": "INDIANAPOLIS",
        "country": null,
        "postal_code": "46203",
        "state": "IN"
      },
      "original_estimated_delivered_at": "2019-01-30T13:30:00",
      "scan_events": [
        {
          "carrier_code": "GX",
          "description": "Shipping Label Created, USPS Awaiting Item",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN",
          },
          "message": "January 28 1:23 pm Shipping Label Created, USPS Awaiting Item in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T13:23:00",
          "source": "USPS",
          "status": "pre_transit",
          "status_detail": "label_created"
        },
        {
          "carrier_code": "OA",
          "description": "Accepted at USPS Origin Facility",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 28 8:29 pm Accepted at USPS Origin Facility in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-28T20:29:00",
          "source": "USPS",
          "status": "in_transit",
          "status_detail": "received_at_origin_facility"
        },
        {
          "carrier_code": "OF",
          "description": "Out for Delivery",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 9:16 am Out for Delivery in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T09:16:00",
          "source": "USPS",
          "status": "out_for_delivery",
          "status_detail": "out_for_delivery"
        },
        {
          "carrier_code": "01",
          "description": "Delivered, In/At Mailbox",
          "location": {
            "city": "INDIANAPOLIS",
            "country": null,
            "postal_code": "46203",
            "state": "IN"
          },
          "message": "January 30 1:30 pm Delivered, In/At Mailbox in INDIANAPOLIS, IN",
          "scanned_at": "2019-01-30T13:30:00",
          "source": "USPS",
          "status": "delivered",
          "status_detail": "arrived_at_destination"
        }
      ],
      "signed_by": "null",
      "status": "delivered",
      "tracking_code": "9400000000000000000000",
      "weight": null
    }
  ],
  "updated_at": "2019-01-30T13:30:00Z"
}
```

{% endtab %}
{% endtabs %}

## Delete an Order

<mark style="color:red;">`DELETE`</mark> `https://api.gomalomo.com/orders/:id`

#### Path Parameters

| Name | Type   | Description                           |
| ---- | ------ | ------------------------------------- |
| id   | string | Unique identifier of the order delete |

{% tabs %}
{% tab title="204 " %}

{% endtab %}
{% endtabs %}

## Create an Event for an Order

<mark style="color:green;">`POST`</mark> `https://api.gomalomo.com/orders/:order_id/events`

#### Path Parameters

| Name      | Type   | Description                                        |
| --------- | ------ | -------------------------------------------------- |
| order\_id | string | Unique id of the `Order` to create an `Event` for. |

#### Request Body

| Name            | Type    | Description                                                                                                           |
| --------------- | ------- | --------------------------------------------------------------------------------------------------------------------- |
| label           | string  | Human-friendly text describing the event.                                                                             |
| link\_back\_url | string  | URL pointing to a 3rd party resources that may be relevant to an event.                                               |
| properties      | object  | Arbitrary data relevant to the event.                                                                                 |
| timestamp       | integer | A unix timestamp of when the event occurred. If not provided the timestamp will default to the current date and time. |
| type            | string  | Type of event. This value should be consistent for the same types of event.                                           |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "created_at": "2019-01-30T13:30:00Z",
  "id": "1a3c1090-efd1-11eb-9a03-0242ac130003",
  "label": "Order #1000 fulfilled",
  "link_back_url": "https://goodest-boi.myshopify.com/admin/orders/5555555555555",
  "properties": {
    "shopify_order": {
      "id": "5555555555555"
    }
  },
  "timestamp": 1548855000
  "type": "ShopifyOrderFulfilled",
  "updated_at": "2019-01-30T13:30:00Z",
}
```

{% endtab %}
{% endtabs %}

## Retrieve a List of Order Events

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/orders/:order_id/events`

#### Path Parameters

| Name      | Type   | Description                                      |
| --------- | ------ | ------------------------------------------------ |
| order\_id | string | Unique id of the `Order` to retrieve events for. |

#### Query Parameters

| Name | Type   | Description                            |
| ---- | ------ | -------------------------------------- |
| prev | string | Retrieve events before a given cursor. |
| next | string | Retrieve events after a given cursor.  |

{% tabs %}
{% tab title="200 " %}

```javascript
[
  {
    "created_at": "2019-01-30T13:30:00Z",
    "id": "1a3c1090-efd1-11eb-9a03-0242ac130003",
    "label": "Order #1000 fulfilled",
    "link_back_url": "https://goodest-boi.myshopify.com/admin/orders/5555555555555",
    "properties": {
      "shopify_order": {
        "id": "5555555555555"
      }
    },
    "timestamp": 1548855000
    "type": "ShopifyOrderFulfilled",
    "updated_at": "2019-01-30T13:30:00Z",
  }
]
```

{% endtab %}
{% endtabs %}


# Customer

![](https://2604198532-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-Ljb6kldSmEV1tpebdRd%2F-LruCvTGKE0sxF9K9xmg%2F-LruD-Qxfb6CHfkqDnrA%2FResource%20Map%20-%20Customer.png?alt=media\&token=99f1c53a-a0d5-41b1-860b-c276867901b7)

### Customer Properties

| Field          | Description                                           |
| -------------- | ----------------------------------------------------- |
| `created_at`   | When a `Customer` was created on the Malomo Platform. |
| `email`        | Customer's email address.                             |
| `first_name`   | Customer's first name.                                |
| `id`           | Unique identifier for a `Customer`.                   |
| `last_name`    | Customer's last name.                                 |
| `phone_number` | Customer's phone number.                              |
| `updated_at`   | When a `Customer` was last updated.                   |

## Create a Customer

<mark style="color:green;">`POST`</mark> `https://api.gomalomo.com/customers`

#### Request Body

| Name          | Type   | Description              |
| ------------- | ------ | ------------------------ |
| email         | string | Customer's email address |
| first\_name   | string | Customer's first name    |
| last\_name    | string | Customer's last name     |
| phone\_number | string | Customer's phone number  |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "created_at": "2019-01-30T13:30:00Z",
  "email": "johnny@rosevideo.com",
  "first_name": "Johnny",
  "id": "a0a877c6-4164-4e8a-8179-48f8d4752b4e",
  "last_name": "Rose",
  "phone_number": "555-555-5555",
  "updated_at": "2019-01-30T13:30:00Z"
}
```

{% endtab %}
{% endtabs %}

## Retrieve a Customer

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/customers/:id`

#### Path Parameters

| Name | Type   | Description                               |
| ---- | ------ | ----------------------------------------- |
| id   | string | Unique identifier of the desired customer |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "created_at": "2019-01-30T13:30:00Z",
  "email": "johnny@rosevideo.com",
  "first_name": "Johnny",
  "id": "a0a877c6-4164-4e8a-8179-48f8d4752b4e",
  "last_name": "Rose",
  "phone_number": "555-555-5555",
  "updated_at": "2019-01-30T13:30:00Z"
}
```

{% endtab %}
{% endtabs %}

## Retrieve a List of Customers

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/customers`

#### Query Parameters

| Name | Type   | Description                               |
| ---- | ------ | ----------------------------------------- |
| prev | string | Retrieve customers after a given cursor.  |
| next | string | Retrieve customers before a given cursor. |

{% tabs %}
{% tab title="200 " %}

```javascript
[
  {
    "created_at": "2019-01-30T13:30:00Z",
    "email": "johnny@rosevideo.com",
    "first_name": "Johnny",
    "id": "a0a877c6-4164-4e8a-8179-48f8d4752b4e"
    "last_name": "Rose",
    "phone_number": "555-555-5555",
    "updated_at": "2019-01-30T13:30:00Z"
  }
]
```

{% endtab %}
{% endtabs %}

## Update a Customer

<mark style="color:orange;">`PUT`</mark> `https://api.gomalomo.com/customers/:id`

#### Path Parameters

| Name | Type   | Description                                 |
| ---- | ------ | ------------------------------------------- |
| id   | string | Unique identifier of the customer to update |

#### Request Body

| Name          | Type   | Description              |
| ------------- | ------ | ------------------------ |
| email         | string | Customer's email address |
| first\_name   | string | Customer's first name    |
| last\_name    | string | Customer's last name     |
| phone\_number | string | Customer's phone number  |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "created_at": "2019-01-30T13:30:00Z",
  "email": "johnny@rosevideo.com",
  "first_name": "Johnny",
  "id": "a0a877c6-4164-4e8a-8179-48f8d4752b4e",
  "last_name": "Rose",
  "phone_number": "555-555-5555",
  "updated_at": "2019-01-30T13:30:00Z"
}
```

{% endtab %}
{% endtabs %}

## Delete a Customer

<mark style="color:red;">`DELETE`</mark> `https://api.gomalomo.com/customers/:id`

#### Path Parameters

| Name | Type   | Description                                 |
| ---- | ------ | ------------------------------------------- |
| id   | string | Unique identifier of the customer to delete |

{% tabs %}
{% tab title="204 " %}

{% endtab %}
{% endtabs %}

## Retrieve a List of Customer Events

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/customers/:customer_id/events`

#### Path Parameters

| Name         | Type   | Description                                       |
| ------------ | ------ | ------------------------------------------------- |
| customer\_id | string | Unique id of the Customer to retrieve events for. |

#### Query Parameters

| Name | Type   | Description                            |
| ---- | ------ | -------------------------------------- |
| prev | string | Retrieve events before a given cursor. |
| next | string | Retrieve events after a given cursor.  |

{% tabs %}
{% tab title="200 " %}

```javascript
[
  {
    "created_at": "2019-01-30T13:30:00Z",
    "id": "1a3c1090-efd1-11eb-9a03-0242ac130003",
    "label": "Order #1000 fulfilled",
    "link_back_url": "https://goodest-boi.myshopify.com/admin/orders/5555555555555",
    "properties": {
      "shopify_order": {
        "id": "5555555555555"
      }
    },
    "timestamp": 1548855000
    "type": "ShopifyOrderFulfilled",
    "updated_at": "2019-01-30T13:30:00Z",
  }
]
```

{% endtab %}
{% endtabs %}


# Webhook

### Webhook Properties

| Field        | Description                                                                                         |
| ------------ | --------------------------------------------------------------------------------------------------- |
| `active`     | Whether events should be sent to this webhook. Can be either `true`or `false`. Defaults  to `true`. |
| `created_at` | When a `Webhook` was created on the Malomo Platform.                                                |
| `id`         | Unique identifier per `Webhook`.                                                                    |
| `topic`      | Event that triggers a webhook.                                                                      |
| `updated_at` | When a `Webhook` was last updated.                                                                  |
| `url`        | URL webhook events should be sent to.                                                               |

## Create a Webhook

<mark style="color:green;">`POST`</mark> `https://api.gomalomo.com/webhooks`

#### Request Body

| Name   | Type    | Description                                              |
| ------ | ------- | -------------------------------------------------------- |
| active | boolean | Whether to send events to a webhook. Defaults to `true`. |
| secret | string  | Key used to sign webhook events.                         |
| topic  | string  | Event that triggers a webhook.                           |
| url    | string  | URL to send webhook events to.                           |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "active": true,
  "created_at": "2019-01-30T13:30:00Z",
  "id": "be005f40-f068-4ca6-a936-f11b2f902ffc",
  "topic": "events:created",
  "updated_at": "2019-01-30T13:30:00Z",
  "url": "https://myapp.com/webhooks"
}
```

{% endtab %}
{% endtabs %}

## Retrieve a Webhook

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/webhooks/:id`

#### Path Parameters

| Name | Type   | Description                                 |
| ---- | ------ | ------------------------------------------- |
| id   | string | Unique identifier of the desired `Webhook`. |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "active": true,
  "created_at": "2019-01-30T13:30:00Z",
  "id": "be005f40-f068-4ca6-a936-f11b2f902ffc",
  "topic": "events:created",
  "updated_at": "2019-01-30T13:30:00Z",
  "url": "https://myapp.com/webhooks"
}
```

{% endtab %}
{% endtabs %}

## Retrieve a List of Webhooks

<mark style="color:blue;">`GET`</mark> `https://api.gomalomo.com/webhooks`

#### Query Parameters

| Name | Type   | Description                              |
| ---- | ------ | ---------------------------------------- |
| prev | string | Retrieve webhooks before a given cursor. |
| next | string | Retrieve webhooks after a given cursor.  |

{% tabs %}
{% tab title="200 " %}

```javascript
[
  {
    "active": true,
    "created_at": "2019-01-30T13:30:00Z",
    "id": "be005f40-f068-4ca6-a936-f11b2f902ffc",
    "topic": "events:created",
    "updated_at": "2019-01-30T13:30:00Z",
    "url": "https://myapp.com/webhooks"
  }
]
```

{% endtab %}
{% endtabs %}

## Update a Webhook

<mark style="color:orange;">`PUT`</mark> `https://api.gomalomo.com/webhooks/:id`

#### Path Parameters

| Name | Type   | Description                                   |
| ---- | ------ | --------------------------------------------- |
| id   | string | Unique identifier of the `Webhook` to update. |

#### Request Body

| Name   | Type    | Description                          |
| ------ | ------- | ------------------------------------ |
| active | boolean | Whether to send events to a webhook. |
| url    | string  | URL to send webhook events to.       |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "active": true,
  "created_at": "2019-01-30T13:30:00Z",
  "id": "be005f40-f068-4ca6-a936-f11b2f902ffc",
  "topic": "events:created",
  "updated_at": "2019-01-30T13:30:00Z",
  "url": "https://myapp.com/webhooks"
}
```

{% endtab %}
{% endtabs %}

## Delete a Webhook

<mark style="color:red;">`DELETE`</mark> `https://api.gomalomo.com/webhooks/:id`

#### Path Parameters

| Name | Type   | Description                                       |
| ---- | ------ | ------------------------------------------------- |
| id   | string | Unique identifier of the `Webhook` to be deleted. |

{% tabs %}
{% tab title="204 " %}

{% endtab %}
{% endtabs %}


# Integrate with Malomo.js

Set up Malomo.js to create premium post-purchase experiences

### Set up Malomo.js

Include the following script in the head section of your tracking page. This script must always load directly from **js.gomalomo.com**. You can't include the script in a bundle or host a copy of it yourself.

```javascript
<script src="https://js.gomalomo.com/v2/" type="application/javascript"></script>
```

### Set up Malomo Elements

Elements is available as part of Malomo.js and provides drop-in UI components that you can use to build premium post-purchase experiences.

To create an instance of Elements, use the following JavaScript code.

```javascript
var malomo = Malomo('pk_dd475cb111b894c84e8c0af84e500795');
var elements = malomo.elements();
```

Replace the sample API key with your publishable key. This will allow you to use your Malomo account when using Malomo.js.

### HTTPS Requirement

When you use Elements, all information is submitted over a secure HTTPS connection. To protect yourself from certain forms of man-in-the-middle attacks, and to prevent your customers from seeing [Mixed Content](https://developers.google.com/web/fundamentals/security/prevent-mixed-content/what-is-mixed-content) warnings in modern browsers, you must serve the page that contains Malomo.js over HTTPS as well.

In short, the address of the page that contains Elements must start with **https\://** rather than **http\://.**


# Add a tracking block to your website using Malomo.js

Malomo.js is a powerful tool that allows you to easily add a tracking block to a website you host and manage. This gives you complete control over the content and design of a page while being able to provide your customers with the order tracking information they need.

Please note that in order to use Malomo.js you should have a basic understanding of web development tools like HTML, CSS and JavaScript.

### Add the Malomo tracking block to your website

#### Adding Malomo.js on your website

To get started add the following script tag to the head section of a page you want to render a Malomo tracking block on. We recommend only adding Malomo.js to the pages that are using it.

```html
<script src="https://js.gomalomo.com/v2/" type="application/javascript"></script>
```

For more information and restrictions on including Malomo.js on your site please see [Integrate with Malomo.js](/malomo.js/integrate-with-malomo.js).

#### Adding the Malomo tracking block

To add a tracking block to your website copy and paste the following code inside your `<body>` tag just before `</body>`.

```javascript
<script type="application/javascript">
(function() {
  //
  // Start config
  //
   
  let apiKey = '';

  let mountPoint = '';
   
  //
  // End config
  //

  let malomo = Malomo(apiKey);
   
  let elements = malomo.elements();
   
  malomo.fetchOrder()
    .then((order) => {
      return elements
        .create(
          'shipmentTracker',
          {
            order: order
          }
        )
        .mount(mountPoint);
    })
    .catch(() => {
      return elements
        .create(
          'orderLookup',
          {
            callback: (resp) => {
              let url = new URL(document.URL);
           
              url.searchParams.append('_m_id', resp.body['id']);
           
              window.location.href = url;
            }
          }
        )
        .mount(mountPoint);
    });
})();
</script>
```

You need to supply the code above with two pieces of information.

1. `apiKey` - your publishable Malomo API key. Publishable keys are prefixed with `pk_`.  You can create a publishable API key in your Malomo [developer dashboard](https://dash.gomalomo.com/account/developer).
2. `mountPoint` - the HTML element the tracking block will be rendered within. You can specify the element using [CSS selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors). We recommend using an ID selector.

The code above will render a tracking block complete with order lookup.

### How does this work?

The code above works by attempting to retrieve a Malomo order using the [`malomo.fetchOrder()`](https://docs.gomalomo.com/malomo.js/pages/-Lqg3ccMLAtnZmDZCevX#malomo.fetchorder) function. If an order was found it will render a tracking block. If the order could not be found an order lookup form will be rendered instead.

### What next?

At this point all that is left is for you to style the Malomo tracking block. You have complete control over the look and feel of the tracking block using CSS. Please check out our [Malomo.js Reference](/malomo.js/malomo.js-reference) for additional details on using Malomo.js and how you can further customize a tracking block.


# Malomo.js Reference

Build modern post-purchase experiences for the web

This is the API reference for Malomo.js. Use Malomo.js' API to retrieve shipment information and build delightful post-purchase experiences for your customers.

### Including Malomo.js

However you're using Malomo.js, you always begin by including the library and setting your API key. To get started, include this script on your pages -- it should always be loaded directly from **<https://js.gomalomo.com/v2/>**:

```javascript
<script src="https://js.gomalomo.com/v2/"></script>
```

### `Malomo` object

#### `Malomo(publishableKey[, options])`

Use `Malomo(publishableKey[, options])` to create an instance of the `Malomo` object. Your Malomo publishable key is required when calling this function as it identifies your account.

This function accepts an optional `options` object. Available options are documented below:

* `url` - the URL used when making API calls. Defaults to `https://api.gomalomo.com`.

#### `malomo.elements()`

Create pre-built UI components that allow you to add post-purchase elements to any page.

#### `malomo.retrieveOrder(query)`

Retrieve an `Order` using either it's `id` or `alternate_id`.

```javascript
malomo.retrieveOrder({ id: 'ccb71edc-2952-4709-8880-9cb08c26724a' })
  .then(
    function(response) {
      // Handle response
    }
  );
```

Please note that `metadata` will not be included on `Order` objects when using Malomo.js.

This method will return a `Promise` which resolves with a `Response` object. This object contains `body`, `headers` and `status` properties.

#### `malomo.fetchOrder()`

Retrieve an Order by automatically using values stored as URL query parameters `_m_id` and `_m_alt_id`. If both `_m_id` and `_m_alt_id` are both present then `_m_id` will be used.

```javascript
malomo.fetchOrder()
  .then(
    function(response) {
      // Handle response
    }
  );
```

This method will return a `Promise` which resolves with an array of `Response` objects. This object contains `body`, `headers` and `status` properties.

### `Elements` object

#### `elements.create(type, options)`

Creates an instance of a specific Element. This method takes a `type` of Element to create and an `options` object.

**Element `type`**

* `shipmentTracker` - renders a complete block that can be used for displaying the status of a shipment

**Element `options`**

* `classNamePrefix` - a string appended to all CSS class names rendered by an element. Defaults to `malomo`.

#### `elements.create('shipmentTracker', options)`

Creates an Element that renders a complete shipment tracking experience.

\
**Options**

<table data-header-hidden><thead><tr><th width="385">Option</th><th>Description</th></tr></thead><tbody><tr><td><code>appearance.theme</code></td><td>A theme that can be used to style the appearance of Malomo.js. Supported value is <code>light</code>.</td></tr><tr><td><code>order</code> <strong>(required)</strong></td><td>The <code>Order</code> object provided to this Element.</td></tr><tr><td><code>carrierInfo.linkToCarrier</code></td><td>A boolean that determines whether to render a tracking code as text or a link that can take a user to the carriers tracking page.</td></tr><tr><td><code>carrierInfo.rootClassName</code></td><td>The class name to use for the root carrier info element. Note that <code>classNamePrefix</code> is still applied to the generated class name. Defaults to <code>carrier-info</code>.</td></tr><tr><td><code>carrierInfo.showIf</code></td><td>A function to determine whether to render carrier information. If the function returns <code>false</code> carrier information will not be rendered. If <code>true</code> is returned then carrier information will be rendered. An <code>Order</code> object will be passed as the first argument and a <code>Shipment</code> object as the second argument. Defaults to <code>true</code>.</td></tr><tr><td><code>carrierInfo.showImage</code></td><td>A boolean that determines whether to render the carrier logo. If <code>false</code> the image will not be shown. Defaults to <code>true</code>.</td></tr><tr><td><code>corso.shopId</code></td><td>A shop id associated with a Corso account. When present this will enable Corso support when rendering the <code>shipmentTracker</code> element.</td></tr><tr><td><code>countdown.minDaysLeft</code></td><td>An integer indicating when to render a countdown depending on how many days are left until a shipment is delivered. A countdown will not contain a value until the number of days left is equal or less than the value of this options. If a value is not provided then the countdown will always contain a value as long as the number of days left is greater than zero.</td></tr><tr><td><code>countdown.rootClassName</code></td><td>The class name to use for the root countdown element. Note that <code>classNamePrefix</code> is still applied to the generated class name. Defaults to <code>countdown</code>.</td></tr><tr><td><code>countdown.showIf</code></td><td>A function to determine whether to render a countdown. If the function returns <code>false</code> a countdown will not be rendered. If <code>true</code> is returned then a countdown will be rendered. An <code>Order</code> object will be passed as the first argument and a <code>Shipment</code> object as the second argument. Defaults to <code>true</code>.</td></tr><tr><td><code>deliveryDate.format</code></td><td>The format the date will be displayed as. Defaults to <code>EEEE, MMMM d</code> (e.g. Saturday, February 29). For more information on how to format a date please see <a href="https://date-fns.org/v2.4.1/docs/format">date-fn's <code>format</code> documentation</a>.</td></tr><tr><td><code>deliveryDate.rootClassName</code></td><td>The class name to use for the delivery date root element. Note that <code>classNamePrefix</code> is still applied to the generated class name. Defaults to <code>delivery-date</code>.</td></tr><tr><td><code>deliveryDate.showIf</code></td><td>A function to determine whether to render a delivery date. If the function returns <code>false</code> a delivery date will not be rendered. If <code>true</code> is returned then a delivery date will be rendered. An <code>Order</code> object will be passed as the first argument and a <code>Shipment</code> object as the second argument. Defaults to <code>true</code>.</td></tr><tr><td><code>deliveryState.rootClassName</code></td><td>The class name to use for the delivery state root element. Note that <code>classNamePrefix</code> is still applied to the generated class name. Defaults to <code>delivery-state</code>.</td></tr><tr><td><code>deliveryState.showIf</code></td><td>A function to determine whether to render a delivery state. If the function returns <code>false</code> a delivery state will not be rendered. If <code>true</code> is returned then a delivery state will be rendered. An <code>Order</code> object will be passed as the first argument and a <code>Shipment</code> object as the second argument. Defaults to <code>true</code>.</td></tr><tr><td><code>deliveryState.states</code></td><td>An object containing overrides for the state to display. Defaults are provided below.</td></tr><tr><td><code>events.dateFormat</code></td><td>The format of the date to be displayed for each event. Defaults to <code>MM d</code> (e.g. February 29). For more information on how to format a date please see <a href="https://date-fns.org/v2.4.1/docs/format">date-fn's <code>format</code> documentation</a>.</td></tr><tr><td><code>events.enumerate</code></td><td>A function that can apply enumeration logic to the events. This is can be used for sorting or filtering out events. An array of events will be passed as the only argument.</td></tr><tr><td><code>events.rootClassName</code></td><td>The class name to use for each shipping event root element. Note that <code>classNamePrefix</code> is still applied to the generated class name. Defaults to <code>events</code>.</td></tr><tr><td><code>events.showIf</code></td><td>A function to determine whether to render shipment events. If the function returns <code>false</code> then shipment events will not be rendered. If <code>true</code> is returned then shipment events will be rendered. An <code>Order</code> object will be passed as the first argument and a <code>Shipment</code> object as the second argument. Defaults to <code>true</code>.</td></tr><tr><td><code>events.timeFormat</code></td><td>The format for the time to be displayed for each event. Defaults to <code>h:mm a</code> (e.g. 12:00 AM). For more information on how to format a date please see <a href="https://date-fns.org/v2.4.1/docs/format">date-fn's <code>format</code> documentation</a>.</td></tr><tr><td><code>returnActions.initiateReturnLinkText</code></td><td>The text for the "initiate return" link that deep links into the returns platform. Defaults to <code>Start a return or an exchange</code></td></tr><tr><td><code>returnActions.initiateReturnPromptText</code></td><td>The prompt text that appears next to the "initiate return" link. Defaults to <code>Need to make a change?</code></td></tr><tr><td><code>returnActions.relatedReturnsText</code></td><td>Header text for the "related returns" section. Below that section are all the returns/exchanges related to the current order being tracked. Defaults to <code>Related Returns</code></td></tr><tr><td><code>returnActions.returnStatusLinkText</code></td><td>The text for the "Return Status" button that allows customers to view the status of their return. Defaults to <code>Return Status</code></td></tr><tr><td><code>returnActions.rootClassName</code></td><td>The class name prefix to use for each element in the "return actions" section. Defaults to <code>return-actions</code></td></tr><tr><td><code>returnActions.showIf</code></td><td>A function to determine whether to render the "return actions" section/any returns or exchanges information. If the function returns <code>false</code> then the customer will not have an ability to interact with returns or exchanges on the tracking page.<br><br>Defaults to <code>true</code> if the Loop Returns integration is installed correctly, and if at least one shipment from the order has been <code>delivered</code>.<br><br>To remove the requirement for the order to have a <code>delivered</code> shipment, you can set the function to:<br><br><code>(order) => { return order.body.return_url; }</code></td></tr><tr><td><code>returnActions.viewOriginalOrderLinkText</code></td><td>The text for the link back to the original order when viewing a return. Defaults to <code>View original order</code></td></tr><tr><td><code>statusMessage.messages</code></td><td>An object containing overrides for the message to display. Defaults are provided below.</td></tr><tr><td><code>statusMessage.rootClassName</code></td><td>The class name to use for the status message root element. Note that <code>classNamePrefix</code> is still applied to the generated class name. Defaults to <code>status-message</code>.</td></tr><tr><td><code>statusMessage.showIf</code></td><td>A function to determine whether to render a status message. If the function returns <code>false</code> then a status message will not be rendered. If <code>true</code> is returned then a status message will be rendered. An <code>Order</code> object will be passed as the first argument and a <code>Shipment</code> object as the second argument. Defaults to <code>true</code>.</td></tr><tr><td><code>statusMessage.stopOn</code></td><td>An array of status keys that will only render the provided statuses if they occur in a shipments tracking history. This is useful in situations like <code>return_to_sender</code> where it may be more useful to show the end user the <code>return_to_sender</code> status message rather than the remaining event statuses as it makes it's way back to the sender. Defaults to <code>false</code>.</td></tr></tbody></table>

{% tabs %}
{% tab title="HTML" %}

```markup
<div id="shipment-tracker"></div>
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
let element = elements.create('shipmentTracker', {order: order});

element.mount('#shipment-tracker');
```

{% endtab %}

{% tab title="Result" %}

```markup
<div id="shipment-tracker">
  <div class="malomo-shipment-tracker">
    <div class="malomo-shipment-tracker-header">
      <div class="malomo-shipment-tracker-delivery-state">
        Estimated Delivery
      </div>
      <div class="malomo-shipment-tracker-delivery-date">
        Monday, August 2
      </div>
    </div>
    <div class="malomo-shipment-tracker-body">
      <div class="malomo-shipment-tracker-countdown">
        4 days left
      </div>
      <div class="malomo-shipment-tracker-history">
        <div class="malomo-shipment-tracker-latest-activity">
          Latest Activity
        </div>
        <div class="malomo-shipment-tracker-most-recent-event">
          <div class="malomo-shipment-tracker-event">
            <div class="malomo-shipment-tracker-event-timestamp">
              <span class="malomo-shipment-tracker-event-timestamp-date">
                July 29
              </span>
              <span class="malomo-shipment-tracker-event-timestamp-time">
                3:53 AM
              </span>
            </div>
            <div class="malomo-shipment-tracker-event-message">
              Arrived at USPS Origin Facility
            </div>
            <div class="malomo-shipment-tracker-event-location">
              <div class="malomo-shipment-tracker-event-location-city">
                carson
              </div>
              <div class="malomo-shipment-tracker-event-location-state">
                ca
              </div>
            </div>
          </div>
        </div>
        <div class="malomo-shipment-tracker-events-backdrop malomo-shipment-tracker-events-toggle">
          <div class="malomo-shipment-tracker-events-modal">
            <div class="malomo-shipment-tracker-events-header">
              <div class="malomo-shipment-tracker-events-header-label">
                History
              </div>
              <div class="malomo-shipment-tracker-events-header-close">
                <img alt="close" class="malomo-shipment-tracker-events-header-close-icon malomo-shipment-tracker-events-toggle" src="https://cdn.gomalomo.com/malomojs/close.svg">
              </div>
            </div>
            <div class="malomo-shipment-tracker-events">
              <div class="malomo-shipment-tracker-event">
                <div class="malomo-shipment-tracker-event-timestamp">
                  <div class="malomo-shipment-tracker-event-timestamp-date">
                    July 29
                  </div>
                  <div class="malomo-shipment-tracker-event-timestamp-time">
                    2:38 AM
                  </div>
                </div>
                <div class="malomo-shipment-tracker-event-message">
                  Accepted at USPS Origin Facility
                </div>
                <div class="malomo-shipment-tracker-event-location">
                  <span class="malomo-shipment-tracker-event-location-city">
                    culver city
                  </span>
                  <span class="malomo-shipment-tracker-event-location-state">
                    ca
                  </span>
                </div>
              </div>
              <div class="malomo-shipment-tracker-event">
                <div class="malomo-shipment-tracker-event-timestamp">
                  <div class="malomo-shipment-tracker-event-timestamp-date">
                    July 27
                  </div>
                  <div class="malomo-shipment-tracker-event-timestamp-time">
                    8:32 PM
                  </div>
                </div>
                <div class="malomo-shipment-tracker-event-message">
                  Shipping Label Created, USPS Awaiting Item
                </div>
                <div class="malomo-shipment-tracker-event-location">
                  <span class="malomo-shipment-tracker-event-location-city">
                    culver city
                  </span>
                  <span class="malomo-shipment-tracker-event-location-state">
                    ca
                  </span>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div class="malomo-shipment-tracker-footer">
      <a class="malomo-shipment-tracker-history-control malomo-shipment-tracker-events-toggle">
        Show History
      </a>
      <div class="malomo-shipment-tracker-carrier-info">
        <img alt="usps" class="malomo-shipment-tracker-carrier-info-image" src="https://cdn.gomalomo.com/images/carriers/usps.svg">
        <a href="https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1=9400000000000000000000" target="_blank" rel="noreferrer noopener" class="malomo-shipment-tracker-carrier-info-tracking-code-link">
          9400000000000000000000
        </a>
      </div>
    </div>
  </div>
</div>
```

{% endtab %}
{% endtabs %}

**Delivery state defaults**

* `noDate` - Check back for an estimated delivery date
* `default` - Estimated Delivery
* `delivered` - Delivered

**Status message defaults**

* `unknown` - ready to go
* `pre_transit` - ready to go
* `in_transit` - on its way
* `out_for_delivery` - out for delivery
* `delivered` - delivered
* `available_for_pickup` - available for pickup
* `return to sender` - returning to sender
* `failure` - failed to delivery
* `cancelled` - cancelled
* `error` - error

#### `elements.create('orderLookup', options)`

Creates an Element that renders a complete order lookup experience.

The `orderLookup` element provides a consumer with the ability to lookup their own order. Once an order lookup element is rendered consumer will be able to locate their order by providing either their order number and the email address they made the purchase with or their shipment tracking code.

**Options**

| **Option**                | Description                                                                                                                                            |
| ------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `callback` **(required)** | The function used when an order is successfully located. This function will typically be responsible for redirecting a user to a Malomo tracking page. |
| `rootClassName`           | The class name to use for the root element. Note that `classNamePrefix` is still applied to the generated class name. Defaults to `order-lookup`.      |

{% tabs %}
{% tab title="HTML" %}

```markup
<div id="order-lookup"></div>
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
let classback = function() {
  let url = new URL(document.URL);
  
  url.searchParams.append(`_m_id`, resp.body['id']);
             
  window.location.href = url;
}

let element = elements.create('shipmentTracker', {callback: callback});

element.mount('#order-lookup');
```

{% endtab %}

{% tab title="Result" %}

```markup
<div class="malomo-order-lookup">
  <div class="malomo-order-lookup-header">
    <div class="malomo-order-lookup-error-message">
      We are having trouble locating your order. Please try re-entering
      your order details. If you haven't received your shipping details
      yet, it's possible your order is still being fulfilled and you won't
      be able to track your order yet.
    </div>
  </div>
  <div class="malomo-order-lookup-body">
    <div class="malomo-order-lookup-form">
      <div class="malomo-order-lookup-section-1">
        <div class="malomo-order-lookup-section-1-1">
          <label class="malomo-order-lookup-number-label" for="malomo-order-lookup-number-label">
            Order Number
          </label>
          <input class="malomo-order-lookup-number-input" name="malomo-order-lookup-number" type="text">
        </div>
        <div class="malomo-order-lookup-section-1-2">
          <label class="malomo-order-lookup-customer-email-label" for="malomo-order-lookup-customer-email-label">
            Email Address
          </label>
          <input class="malomo-order-lookup-customer-email-input" name="malomo-order-lookup-customer-email" type="text">
        </div>
      </div>
      <div class="malomo-order-lookup-section-separator">
        or
      </div>
      <div class="malomo-order-lookup-section-2">
        <div class="malomo-order-lookup-section-2-1">
          <label class="malomo-order-lookup-tracking-number-label" for="malomo-order-lookup-tracking-number-label">
            Tracking Number
          </label>
          <input class="malomo-order-lookup-tracking-number-input" name="malomo-order-tracking-number" type="text">
        </div>
      </div>
      <button class="malomo-order-lookup-submit-button" type="submit">
        Track your order
      </button>
    </div>
  </div>
</div>
```

{% endtab %}
{% endtabs %}

### `Element` object

#### `element.mount(domElement)`

Attaches your Element inside a DOM element. This method accepts a CSS selector (e.g. `#shipment-tracker`), an `HTMLElement` or a `Promise` which resolves with an `HTMLElement`.

This method will return a Promise that resolves with the element mounted. You can pass the return value of this method to another mount function to ensure that Element will be mounted in relation to the returned Element.&#x20;

{% tabs %}
{% tab title="HTML" %}

```markup
<div id="some-element"></div>
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
element.mount('#some-element');
```

{% endtab %}

{% tab title="Result" %}

```markup
<div id="delivery-date">
  <div class="malomo-delivery-date">Saturday, February 29</div>
</div>
```

{% endtab %}
{% endtabs %}

#### `element.mountAfter(domElement)`

Similar to `element.mount(domElement)` but attaches your Element *after* the element specified by `domElement`.

{% tabs %}
{% tab title="HTML" %}

```markup
<div>
  <div id="some-element">
    Hello, world!
  </div>
</div>
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
element.mountAfter('#some-element');
```

{% endtab %}

{% tab title="Result" %}

```markup
<div>
  <div id="some-other-element">
    Hello, world!
  </div>
  <div class="malomo-delivery-date">
    Saturday, February 29
  </div>
</div>
```

{% endtab %}
{% endtabs %}

#### `element.mountBefore(domElement)`

Similar to `element.mount(domElement)` but attaches your Element *before* the element specified by `domElement`.

{% tabs %}
{% tab title="HTML" %}

```markup
<div>
  <div id="some-element">
    Hello, world!
  </div>
</div>
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
element.mountBefore('#some-element');
```

{% endtab %}

{% tab title="Result" %}

```markup
<div>
  <div class="malomo-delivery-date">
    Saturday, February 29
  </div>
  <div id="some-other-element">
    Hello, world!
  </div>
</div>
```

{% endtab %}
{% endtabs %}


