Skip to content

Instantly share code, notes, and snippets.

@mrizwan47
Last active April 21, 2023 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrizwan47/d2e4920856d1e039b26bf9d28fd76393 to your computer and use it in GitHub Desktop.
Save mrizwan47/d2e4920856d1e039b26bf9d28fd76393 to your computer and use it in GitHub Desktop.
ShipHero GraphQL API to add Webhook Listener
import requests, json
username = "email@domain.com"
password = "YOURPASSWORDHERE"
webhook = "https://yoursite.com/?shiphero-webhook=819284691"
shop_name = "ShopName"
# Authenticate
auth = requests.post("https://public-api.shiphero.com/auth/token", json={
"username": username,
"password": password
})
access_token = auth.json()['access_token']
refresh_token = auth.json()['refresh_token']
headers = {"Authorization": "Bearer {}".format(access_token)}
add_wh = requests.post("https://public-api.shiphero.com/graphql", headers=headers, json={'query': '''
mutation {
webhook_create(
data: {
name: "Shipment Update"
url: webhook_url
shop_name: shop_name
}
) {
request_id
complexity
webhook {
shared_signature_secret
}
}
}
'''})
print(json.dumps(add_wh.json(), indent=4))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment