This is just a short set of commands that I used to add a dexcom share follower with curl. I am writing this mostly so I remember if I have to do it again, but also if someone else needs it.

This is based off the commands that listed here.

Note: use https://share1.dexcom.com if you have a US account and https://shareous1.dexcom.com for non-US account.

Authenticate

SESSION_ID=$(curl -v -H "Accept: application/json" \
          -H "Content-Type: application/json" \
          -H "User-Agent: Dexcom Share/3.0.2.11 CFNetwork/672.0.2 Darwin/14.0.0" \
          -X POST \
"https://shareous1.dexcom.com/ShareWebServices/Services/General/LoginPublisherAccountByName" -d '{
  "accountName":"<username>",
  "applicationId":"d8665ade-9673-4e27-9ff6-92db4ce13d13",
  "password":"<password>"
}' | tr -d '"')

SESSION_ID is now used to authenticate the other calls like…

List Current Subscribers

curl -v -H "Accept: application/json" \
        -H "Content-Type: application/json" \
        -H "User-Agent: Dexcom Share/3.0.2.11 CFNetwork/672.0.2 Darwin/14.0.0" \
        -X POST \
https://shareous1.dexcom.com/ShareWebServices/Services/Publisher/ListPublisherAccountSubscriptions?sessionId=$SESSION_ID |  jq

If the subscriber is not there then you need to first create a contact…

Create a Contact

CONTACT_ID=$(curl -v -H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "User-Agent: Dexcom Share/3.0.2.11 CFNetwork/672.0.2 Darwin/14.0.0" \
-X POST \
"https://shareous1.dexcom.com/ShareWebServices/Services/Publisher/CreateContact?sessionId=$SESSION_ID&contactName=<name>&emailAddress=<email>"  \
| tr -d '"')

Then you need to send an invite to that contact

Send Invite to Contact

curl -v -H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "User-Agent: Dexcom Share/3.0.2.11 CFNetwork/672.0.2 Darwin/14.0.0" \
-X POST \
"https://shareous1.dexcom.com/ShareWebServices/Services/Publisher/CreateSubscriptionInvitation?sessionId=$SESSION_ID&contactId=$CONTACT_ID" -d '
{
  "AlertSettings": {
    "HighAlert": {
      "MinValue": 200,
      "AlarmDelay": "PT1H",
      "AlertType": 1,
      "IsEnabled": false,
      "RealarmDelay": "PT2H",
      "Sound": "High.wav",
      "MaxValue": 401
    },
    "LowAlert": {
      "MinValue": 39,
      "AlarmDelay": "PT30M",
      "AlertType": 2,
      "IsEnabled": false,
      "RealarmDelay": "PT2H",
      "Sound": "Low.wav",
      "MaxValue": 70
    },
    "FixedLowAlert": {
      "MinValue": 39,
      "AlarmDelay": "PT0M",
      "AlertType": 3,
      "IsEnabled": true,
      "RealarmDelay": "PT30M",
      "Sound": "UrgentLow.wav",
      "MaxValue": 55
    },
    "NoDataAlert": {
      "MinValue": 39,
      "AlarmDelay": "PT1H",
      "AlertType": 4,
      "IsEnabled": false,
      "RealarmDelay": "PT0M",
      "Sound": "NoData.wav",
      "MaxValue": 401
    }
  },
  "Permissions": 1,
  "DisplayName": "<display_name>"
}
'

After this the contact should receive an email with the invite link to start following.

For more info see https://gist.github.com/StephenBlackWasAlreadyTaken/adb0525344bedade1e25