Skip to content

Instantly share code, notes, and snippets.

@DominikAngerer
Last active August 17, 2018 14:58
Show Gist options
  • Select an option

  • Save DominikAngerer/63b8ad1bef656295c7e11b38fef0e959 to your computer and use it in GitHub Desktop.

Select an option

Save DominikAngerer/63b8ad1bef656295c7e11b38fef0e959 to your computer and use it in GitHub Desktop.
Create a Space in Storyblok using Python and a Client structure
import requests
# Got from https://app.storyblok.com/#!/me/account (Personal access token)
auth_token = 'YOUR_TOKEN'
class Client:
def __init__(self, auth_token):
self.auth_token = auth_token
def create_space(self, name, domain, parent='', dup=''):
url = 'https://api.storyblok.com/v1/spaces'
headers = {
'Authorization': self.auth_token
}
payload = {
"space": {
"name": name,
"domain": domain,
}
}
response = requests.post(url, json=payload, headers=headers)
return response
c = Client(auth_token)
res = c.create_space("Space F", "http://example.storyblok.com")
print(res.json())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment