Skip to content

PYTHON – Create organizations

This script uses Python3 to create new organizations in Cloudmore from a CSV file.

Edit the variables under “Define constants” and run the script with Python3.

This is just an example with limited error handling and should not be used for production.

You can easily change the input data from a CSV file to an external system API to create a full automation of creating organizations.

Please update the list of properties you want to submit. The mandatory ones are:

  • Name
  • registrationNumber
  • contact
  • notificationEmail
  • address
  • primaryDomain
import requests
import json
import csv
import base64
# Define constants
RESELLER_ID = '11111111-2222-3333-4444-555555555555' # Replace with you Broker ID
CLIENT_ID = 'ro.customer.client'
API_SECRET = 'MySecret' # Replace with your API Secret
USERNAME = '' # Replace with your username
PASSWORD = 'MyPassword' # Replace with your password
CSV_FILE_PATH = 'organizations.csv'  # Replace with your CSV file path
# Base64 encode the API secret
client_decoded = f'{CLIENT_ID}:{API_SECRET}'
b64_secret = base64.b64encode(client_decoded.encode()).decode()
# Get Access Token using username and password
token_url = ''
token_headers = {'Authorization': f'Basic {b64_secret}'}
token_data = {
    'grant_type': 'password',
    'username': USERNAME,
    'password': PASSWORD,
    'scope': 'api'
token_response =, headers=token_headers, data=token_data)
token = token_response.json().get("access_token")
print('Access Token received:', token)
# Read organizations data from CSV and create organizations
org_creation_url = f'{RESELLER_ID}/Organizations'
org_headers = {
    'Content-Type': 'application/json',
    'Authorization': f'Bearer {token}'
with open(CSV_FILE_PATH, 'r') as csv_file:
    csv_reader = csv.DictReader(csv_file)
    for row in csv_reader:
        organization_data = {
            "name": row['orgName'],
            "registrationNumber": row['registrationNumber'],
            "vat": row['vat'],
            "homePage": row['homePage'],
            "contact": {
                "name": row['contact_name'],
                "email": row['contact_email'],
                "phone": row['contact_phone'],
                "cellPhone": row['contact_cellPhone']
            "customerNumber": row['customerNumber'],
            "notificationEmail": row['notificationEmail'],
            "address": {
                "street": row['address_street'],
                "postalCode": row['address_postalCode'],
                "city": row['address_city'],
                "countryCode": row['address_countryCode']
            "approvalTriggeredOn": int(row['approvalTriggeredOn']),
            "approvalOnQuantityChange": bool(row['approvalOnQuantityChange']),
            "primaryDomain": row['primaryDomain'],
            "customProperties": [
                    "id": row['property_id'],           # Make sure the custom property exists
                    "value": row['property_value']
                # Include other properties as needed...
        response =, headers=org_headers, json=organization_data)
        if response.status_code == 201:
            print(f"Organization '{row['orgName']}' created successfully.")
            print(f"Failed to create organization '{row['orgName']}'.")
            print("Response content:", response.content)
print('Organization creation process completed.')

Example CSV file:

Org Name 1,123456,VAT123,,John Doe,,123-456-7890,987-654-3210,Cust123,,123 Main St,12345,Cityville,US,0,TRUE,,026a22c2-4639-4e96-a200-24ff368038bb,value1
Org Name 2,789012,VAT789,,Jane Smith,,987-654-3210,123-456-7890,Cust456,,456 Elm St,67890,Townsville,GB,1,FALSE,,026a22c2-4639-4e96-a200-24ff368038bb,value2