API batch | Reseller | Account & location creation: counsel

Posted over 1 year ago by Julien Pauthier

  • Pinned Topic
Julien Pauthier
Julien Pauthier Admin

Using API batches, you can change HTTP headers from our request to the others, so that first API request creates an account using your API credentials, and the next ones rely on the newly created account credentials. Here is an example:


POST https://api.agendize.com/api/2.3/batch


{
  "requests": [
    {
      "name": "create-reseller-child-account",
      "path": "/api/2.0/resellers/accounts",
      "method": "POST",
      "body": {
        "clientName": "",
        "currency": "EUR",
        "email": "",
        "firstName": "",
        "lastName": "",
        "preferences": {
          "displayName": "",
          "language": "en",
          "timeZone": "Europe/Paris"
        },
        "status": "enabled",
        "resellerId": "",
        "userName": "",
        "profile": {
          "id": ""
        }
      }
    },
    {
      "name": "create-company",
      "path": "/api/2.1/scheduling/companies",
      "method": "POST",
      "headers": {
        "token": "${result=create-reseller-child-account:$.ssoToken}"
      },
      "body": {
        "name": "Location name",
        "businessCategory": "counsel",
        "address": {
          "city": "Paris",
          "country": "FR",
          "otherStreet": "",
          "state": "",
          "street": "",
          "zipCode": "75001"
        },
        "currency": "EUR",
        "email": "",
        "phone": "",
        "scheduledItems": "service-staff",
        "timeZone": "Europe/Paris",
        "workingHours": [
          {
            "day": "monday",
            "hours": [
              {
                "end": "18:00",
                "start": "14:00"
              }
            ]
          },
          {
            "day": "tuesday",
            "hours": [
              {
                "end": "18:00",
                "start": "09:00"
              }
            ]
          },
          {
            "day": "wednesday",
            "hours": [
              {
                "end": "18:00",
                "start": "09:00"
              }
            ]
          },
          {
            "day": "thursday",
            "hours": [
              {
                "end": "18:00",
                "start": "09:00"
              }
            ]
          },
          {
            "day": "friday",
            "hours": [
              {
                "end": "18:00",
                "start": "09:00"
              }
            ]
          },
          {
            "day": "saturday",
            "hours": [
              {
                "end": "16:00",
                "start": "09:00"
              }
            ]
          },
          {
            "day": "sunday",
            "hours": []
          }
        ]
      }
    },
    {
      "path": "/api/2.1/scheduling/companies/${result=create-company:$.id}/services",
      "method": "POST",
      "headers": {
        "token": "${result=create-reseller-child-account:$.ssoToken}"
      },
      "body": {
        "allowBookingIteration": false,
        "availability": "public",
        "bufferDuration": 0,
        "price": 0,
        "capacity": 1,
        "description": "",
        "color": "#FF5454",
        "duration": 30,
        "maxAppointmentsPerDay": 1,
        "name": "Counsel",
        "overNight": false,
        "overNightStartTime": "",
        "payable": false
      }
    },
    {
      "path": "/api/2.1/scheduling/companies/${result=create-company:$.id}/staff?services=all",
      "method": "POST",
      "headers": {
        "token": "${result=create-reseller-child-account:$.ssoToken}"
      },
      "body": {
        "firstName": "",
        "lastName": "",
        "email": "",
        "description": ""
      }
    },
    {
      "path": "/api/2.1/scheduling/companies/${result=create-company:$.id}/settings",
      "method": "PUT",
      "headers": {
        "token": "${result=create-reseller-child-account:$.ssoToken}"
      },
      "body": {
        "notifications": {
          "clientEmailFeedback": true
        },
        "contact": {
          "managerEmailAddress": ""
        },
        "rules": {
          "validation": "auto",
          "minAppointmentDate": "hours-1",
          "maxAppointmentDate": "months-2",
          "waitingList": false
        },
        "widget": {
          "appointmentForSomeoneElse": false,
          "displayPrices": true,
          "displayDuration": true,
          "displayServicePicture": true,
          "staffMemberNameFormat": "{staff name} {staff lastname}",
          "freeSlotsIntervalTime": "service+buffer",
          "displayConfirmPrintPage": true,
          "displayDescription": true
        },
        "items": {
          "scheduledItems": "staff-service",
          "staffServiceAllowRandomStaff": true
        },
        "reminders": {
          "first": {
            "delay": "1440",
            "email": true,
            "sms": false
          },
          "second": {
            "delay": "60",
            "sms": true,
            "email": false
          },
          "staffReminders": false
        },
        "calendarSync": {
          "googleCalendar": {
            "enabled": true
          },
          "liveCalendar": {
            "office365CalendarEnabled": true,
            "outlookCalendarEnabled": true
          },
          "bidirectionalSync": {
            "enabled": true
          }
        }
      }
    },
    {
      "headers": {
        "token": "${result=create-reseller-child-account:$.ssoToken}"
      },
      "path": "/api/2.1/scheduling/buttons",
      "method": "POST",
      "body": {
        "name": "Booking button",
        "companyId": "${result=create-company:$.id}"
      }
    }
  ]
}


0 Votes


0 Comments

Login or Sign up to post a comment