This guide will show you how to get delivery reports for your recently sent SMS messages through the Infobip Go SDK.
Delivery reports will tell you the specific status of each of your recently sent messages. For detailed information on the full capabilities of the Infobip SMS channel, check the API Reference.

Prerequisites

  • Basic Go and API knowledge
  • Go 13 (or newer) installation
  • A running Go project

Steps overview

  1. Install the Infobip Go SDK.
  2. Import the required packages.
  3. Create an Infobip client.
  4. Send a message, if you haven’t already.
  5. Configure query parameters.
  6. Get the reports.
  7. Check the reports (optional).

Install the Infobip SDK

The SDK can be retrieved as a normal Go library, using the go get command as follows:

go get "github.com/infobip-community/infobip-api-go-sdk/v3"

Import the required packages

You’ll need the Infobip client and models imported into your source code:

import (
    //..
    "github.com/infobip-community/infobip-api-go-sdk/v3/pkg/infobip"
    "github.com/infobip-community/infobip-api-go-sdk/v3/pkg/infobip/models"
)

Create an Infobip client

To create the main client, you need to specify your API key and custom base URL.
You can get them by logging into your Infobip account.

// Secrets configuration
baseURL := "your base URL here"
apiKey := "your api key here"

// Initialize Infobip client
client, _ := infobip.NewClient(baseURL, apiKey)

Send a message, if you haven’t

To get actual data in the report you need to have sent messages recently. If you haven’t, please send a message, following our Send SMS Guide.

Configure query parameters

You can limit the number of messages reported, or reduce the query to a specific message ID or bulk ID. If you want to filter these, specify the ID in the GetSMSDeliveryReportsParams instance.

queryParams := models.GetSMSDeliveryReportsParams{
    BulkID:    "your-bulk-id",
    MessageID: "your-message-id",
    Limit:     10,
}

Get the reports

Call the endpoint to get your delivery reports.

resp, respDetails, _ := client.SMS.GetDeliveryReports(context.Background(), queryParams)

Note that delivery reports can be retrieved only once. A subsequent call to this endpoint will be empty if no new messages have been sent.

Check the reports (optional)

To verify your reports, you can print the response and the return status code.

fmt.Printf("Reports: %+vn", resp)
fmt.Printf("HTTP response: %sn", respDetails.HTTPResponse.Status)

You should be able to see the report’s contents slice and a 200 OK status code.

Reports: {Results:[{BulkID: CallbackData: DoneAt:2022-06-24T20:37:30.932+0000 Error:{Description:No Error GroupID:0 GroupName:OK ID:0 Name:NO_ERROR Permanent:false} From:Cool Gopher MccMnc:null MessageID:35610304960103571556 Price:{PricePerMessage:0 Currency:EUR} SentAt:2022-06-24T20:37:29.633+0000 SmsCount:1 Status:{Action: Description:Message delivered to handset GroupID:3 GroupName:DELIVERED ID:5 Name:DELIVERED_TO_HANDSET} To:523311800428}]}
HTTP response: 200 OK

The reports have many fields that you can access with the . as with any struct.

resp.Results[0].Status.Description
resp.Results[0].MessageID // and so on ...

That’s all for this guide. Thanks for reading!