Skip to content

Instantly share code, notes, and snippets.

@mrizwan47
Last active April 21, 2023 15:05
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
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