Call the SBS API


Now that you have a service access key for the SBS API, you can use it in your program code or business application.

As an example, let’s call the Email Service and send an email.

  1. Download the Postman desktop app from https://www.postman.com/downloads/.

  2. Run the app and sign up for an account (or sign in to your existing account).

  3. Select an existing workspace or create a new one.

    Postman - Create workspace

  4. Click New, and then select GraphQL.

    Postman - Create collection

  5. Enter the URL of the SBS endpoint that you want to call (in this example, https://email-api.socrate.io/graphql).

    Postman - Enter URL

  6. On the Authorization tab, select API Key. Set the key name to x-api-key and the key value to the secret key generated previously.

    Postman - Enter URL

    For security purposes, you will likely want to click Set as Variable and store the key value as a variable. In the screen capture below, the variable name is {{SBS_ACCESS_KEY}}.

    Postman - Variable

  7. On the Query tab, click Use GraphQL Introspection. As a result, the GraphQL schema is loaded from the API.

    Postman - Schema

  8. Enter the GraphQL mutation and variables directly in the upper-right and lower-right text boxes, respectively. The code is included below, for convenience.

    Postman - Query and variables

    mutation sendMessage ($input:SendMessageInput!) {
          sendMessage(
            input: $input
          ) {
            id
            messageId
            from { name address }
            to { name address }
            subject
            textBody
          }
        }
    
    {
          "input": {
          "to": [{ "address": "{{YOUR_EMAIL_ADDRESS}}" }],
            "subject": "Hello from Socrate Business Services!",
            "textBody": "This is a test email"
           }
          }
        
    
  9. Replace {{YOUR_EMAIL_ADDRESS}} as required, and click Query to send the email. If the email was sent successfully, you are presented with a result similar to the one below:

    Postman - Query result