Dispatch

All Sections

API Authentication

Content

    Introduction

    All MolnX services authenticate using a standard OAuth 2.0 flow ...

    OAuth 2.0 Details

    Token URL

    https://api.iam.molnx.com/oauth2/token

    Grant types

    Only the Client Credentials grant type is supported at the moment. You can find the client_id and client_secret values for your application in the application details in the MolnX portal.

    Refresh tokens

    MolnX does not currently support refresh tokens. You should instead request a new token whenever the current one is about to expire.

    Available scopes

    ScopeDescription
    dispatch.all.readRead access to all Dispatch APIs
    dispatch.all.readwriteRead & Write access to all Dispatch APIs
    dispatch.messages.readRead access to the Messages API endpoints
    dispatch.messages.readwriteRead & Write access to the Messages API endpoints
    dispatch.targets.readRead access to the Targets API endpoints
    dispatch.targets.readwriteRead & Write access to the Targets API endpoints
    dispatch.domains.readRead access to the Domains API endpoints
    dispatch.domains.readwriteRead & Write access to the Domains API endpoints

    Requesting and using access tokens

    First we will need to acquire an access token. We do this by making a form-encoded request to the token URL.

    The following example shows us creating a token with the dispatch.messages.read and dispatch.targets.read scopes.

    curl -X POST https://api.iam.molnx.com/oauth2/token \
    -H "Content-Type: application/x-www-form-urlencoded" \
    -F "client_id=CLIENT_ID
    As shown in your application details in the MolnX portal
    " \
    -F "client_secret=CLIENT_SECRET
    As shown in your application details in the MolnX portal
    " \
    -F "scope=dispatch.messages.read%20dispatch.targets.read" \
    -F "grant_type=client_credentials"

    The access token endpoint will return a response like the following:

    HTTP/1.1 200 OK
    Content-Type: application/json
    ...
    {
    "token_type": "Bearer",
    "expires_in": 3599
    This is the number of seconds until the token expires
    ,
    "access_token": "TOKEN
    A JWT encoded access token
    ",
    "scope": "dispatch.messages.read dispatch.targets.read"
    }

    Now that we have an access token ready we can finally start to use it to start scheduling messages:

    $ curl -X POST https://api.dispatch.molnx.com/messages \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer ACCESS_TOKEN
    An OAuth 2 access token
    " \
    -d '
    {
    "targetId": "DI-T-aabbcc1122
    The ID of the target the message will be delivered to.
    ",
    "deliveryTime": "2020-07-01T12:34:00Z
    An ISO 8601 compatible date and time string.
    ",
    "payload": "Hello, World!
    The payload may be any JSON embeddable string
    "
    }
    '