Chilkat Online Tools

PureBasic / Zoom API / Create a sub account

Back to Collection Items

IncludeFile "CkJsonObject.pb"
IncludeFile "CkStringBuilder.pb"
IncludeFile "CkHttp.pb"
IncludeFile "CkHttpResponse.pb"
IncludeFile "CkHttpRequest.pb"

Procedure ChilkatExample()

    ; This example assumes the Chilkat API to have been previously unlocked.
    ; See Global Unlock Sample for sample code.

    http.i = CkHttp::ckCreate()
    If http.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    success.i

    req.i = CkHttpRequest::ckCreate()
    If req.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkHttpRequest::setCkHttpVerb(req, "POST")
    CkHttpRequest::setCkPath(req, "/v2/accounts")
    CkHttpRequest::setCkContentType(req, "multipart/form-data")
    CkHttpRequest::ckAddParam(req,"first_name","e")

    CkHttpRequest::ckAddParam(req,"last_name","ealiquip mollit")

    CkHttpRequest::ckAddParam(req,"email","ealiquip mollitnon Ut dolor c")

    CkHttpRequest::ckAddParam(req,"password","ealiquip mollitnon Ut dolor cdolore dolor velit cupidatat")

    CkHttpRequest::ckAddParam(req,"options","ealiquip mollitnon Ut dolor cdolore dolor velit cupidatat{" + Chr(34) + "share_rc" + Chr(34) + ":false," + Chr(34) + "room_connector_list" + Chr(34) + ":[" + Chr(34) + "irure est" + Chr(34) + "," + Chr(34) + "aliquip culpa mollit ullamco Lorem" + Chr(34) + "]," + Chr(34) + "share_mc" + Chr(34) + ":false," + Chr(34) + "meeting_connector_list" + Chr(34) + ":[" + Chr(34) + "do" + Chr(34) + "," + Chr(34) + "deserunt nisi aliqu" + Chr(34) + "]," + Chr(34) + "pay_mode" + Chr(34) + ":" + Chr(34) + "master" + Chr(34) + "," + Chr(34) + "billing_auto_renew" + Chr(34) + ":true}")

    CkHttpRequest::ckAddParam(req,"account_name","ealiquip mollitnon Ut dolor cdolore dolor velit cupidatat{" + Chr(34) + "share_rc" + Chr(34) + ":false," + Chr(34) + "room_connector_list" + Chr(34) + ":[" + Chr(34) + "irure est" + Chr(34) + "," + Chr(34) + "aliquip culpa mollit ullamco Lorem" + Chr(34) + "]," + Chr(34) + "share_mc" + Chr(34) + ":false," + Chr(34) + "meeting_connector_list" + Chr(34) + ":[" + Chr(34) + "do" + Chr(34) + "," + Chr(34) + "deserunt nisi aliqu" + Chr(34) + "]," + Chr(34) + "pay_mode" + Chr(34) + ":" + Chr(34) + "master" + Chr(34) + "," + Chr(34) + "billing_auto_renew" + Chr(34) + ":true}qui cillum eu labore")

    CkHttpRequest::ckAddParam(req,"sub_reseller_id","ealiquip mollitnon Ut dolor cdolore dolor velit cupidatat{" + Chr(34) + "share_rc" + Chr(34) + ":false," + Chr(34) + "room_connector_list" + Chr(34) + ":[" + Chr(34) + "irure est" + Chr(34) + "," + Chr(34) + "aliquip culpa mollit ullamco Lorem" + Chr(34) + "]," + Chr(34) + "share_mc" + Chr(34) + ":false," + Chr(34) + "meeting_connector_list" + Chr(34) + ":[" + Chr(34) + "do" + Chr(34) + "," + Chr(34) + "deserunt nisi aliqu" + Chr(34) + "]," + Chr(34) + "pay_mode" + Chr(34) + ":" + Chr(34) + "master" + Chr(34) + "," + Chr(34) + "billing_auto_renew" + Chr(34) + ":true}qui cillum eu laboreLorem amet dolor ex nisi")

    CkHttpRequest::ckAddHeader(req,"Authorization","Bearer <access_token>")

    resp.i = CkHttp::ckSynchronousRequest(http,"api.zoom.us",443,1,req)
    If CkHttp::ckLastMethodSuccess(http) = 0
        Debug CkHttp::ckLastErrorText(http)
        CkHttp::ckDispose(http)
        CkHttpRequest::ckDispose(req)
        ProcedureReturn
    EndIf

    sbResponseBody.i = CkStringBuilder::ckCreate()
    If sbResponseBody.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkHttpResponse::ckGetBodySb(resp,sbResponseBody)

    jResp.i = CkJsonObject::ckCreate()
    If jResp.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkJsonObject::ckLoadSb(jResp,sbResponseBody)
    CkJsonObject::setCkEmitCompact(jResp, 0)

    Debug "Response Body:"
    Debug CkJsonObject::ckEmit(jResp)

    respStatusCode.i = CkHttpResponse::ckStatusCode(resp)
    Debug "Response Status Code = " + Str(respStatusCode)
    If respStatusCode >= 400
        Debug "Response Header:"
        Debug CkHttpResponse::ckHeader(resp)
        Debug "Failed."
        CkHttpResponse::ckDispose(resp)

        CkHttp::ckDispose(http)
        CkHttpRequest::ckDispose(req)
        CkStringBuilder::ckDispose(sbResponseBody)
        CkJsonObject::ckDispose(jResp)
        ProcedureReturn
    EndIf

    CkHttpResponse::ckDispose(resp)

    ; Sample JSON response:
    ; (Sample code for parsing the JSON response is shown below)

    ; {
    ;   "id": "string",
    ;   "owner_id": "string",
    ;   "owner_email": "string",
    ;   "created_at": "string"
    ; }

    ; Sample code for parsing the JSON response...
    ; Use this online tool to generate parsing code from sample JSON: Generate JSON Parsing Code

    id.s = CkJsonObject::ckStringOf(jResp,"id")
    owner_id.s = CkJsonObject::ckStringOf(jResp,"owner_id")
    owner_email.s = CkJsonObject::ckStringOf(jResp,"owner_email")
    created_at.s = CkJsonObject::ckStringOf(jResp,"created_at")


    CkHttp::ckDispose(http)
    CkHttpRequest::ckDispose(req)
    CkStringBuilder::ckDispose(sbResponseBody)
    CkJsonObject::ckDispose(jResp)


    ProcedureReturn
EndProcedure

Curl Command

curl -X POST
	-H "Authorization: Bearer <access_token>"
	-H "Content-Type: multipart/form-data"
	--form 'first_name=e'
	--form 'last_name=ealiquip mollit'
	--form 'email=ealiquip mollitnon Ut dolor c'
	--form 'password=ealiquip mollitnon Ut dolor cdolore dolor velit cupidatat'
	--form 'options=ealiquip mollitnon Ut dolor cdolore dolor velit cupidatat{"share_rc":false,"room_connector_list":["irure est","aliquip culpa mollit ullamco Lorem"],"share_mc":false,"meeting_connector_list":["do","deserunt nisi aliqu"],"pay_mode":"master","billing_auto_renew":true}'
	--form 'account_name=ealiquip mollitnon Ut dolor cdolore dolor velit cupidatat{"share_rc":false,"room_connector_list":["irure est","aliquip culpa mollit ullamco Lorem"],"share_mc":false,"meeting_connector_list":["do","deserunt nisi aliqu"],"pay_mode":"master","billing_auto_renew":true}qui cillum eu labore'
	--form 'sub_reseller_id=ealiquip mollitnon Ut dolor cdolore dolor velit cupidatat{"share_rc":false,"room_connector_list":["irure est","aliquip culpa mollit ullamco Lorem"],"share_mc":false,"meeting_connector_list":["do","deserunt nisi aliqu"],"pay_mode":"master","billing_auto_renew":true}qui cillum eu laboreLorem amet dolor ex nisi'
https://api.zoom.us/v2/accounts

Postman Collection Item JSON

{
  "name": "Create a sub account",
  "request": {
    "method": "POST",
    "header": [
      {
        "key": "Content-Type",
        "value": "multipart/form-data"
      }
    ],
    "body": {
      "mode": "formdata",
      "formdata": [
        {
          "key": "first_name",
          "value": "e",
          "description": "(Required) User's first name.",
          "type": "text"
        },
        {
          "key": "last_name",
          "value": "aliquip mollit",
          "description": "(Required) User's last name.",
          "type": "text"
        },
        {
          "key": "email",
          "value": "non Ut dolor c",
          "description": "(Required) User's email address.",
          "type": "text"
        },
        {
          "key": "password",
          "value": "dolore dolor velit cupidatat",
          "description": "(Required) User's password.\n\n**Note:** If the account owner or admin has enabled [enhanced password requirements](https://support.zoom.us/hc/en-us/articles/360034675592-Advanced-security-settings#h_fa9186e4-6818-4f7a-915c-2e25c19f0acd), the value provided in this field must meet those requirements. These requirements can be retrieved by calling the [Get Account Settings API](https://marketplace.zoom.us/docs/api-reference/zoom-api/accounts/accountsettings) and referring to the `password_requirement` field present in the `security` object.",
          "type": "text"
        },
        {
          "key": "options",
          "value": "{\"share_rc\":false,\"room_connector_list\":[\"irure est\",\"aliquip culpa mollit ullamco Lorem\"],\"share_mc\":false,\"meeting_connector_list\":[\"do\",\"deserunt nisi aliqu\"],\"pay_mode\":\"master\",\"billing_auto_renew\":true}",
          "description": "Account options object.",
          "type": "text"
        },
        {
          "key": "account_name",
          "value": "qui cillum eu labore",
          "description": "Name of the account. If you do not provide a value for this field, by default, the value will be set as a concatenation of \"first_name\" and \"last_name\". ",
          "type": "text"
        },
        {
          "key": "sub_reseller_id",
          "value": "Lorem amet dolor ex nisi",
          "description": "The sub-reseller's ID.\n\nIf you do not provide this field in the payload, a new subaccount will be created for the requested account.",
          "type": "text"
        }
      ]
    },
    "url": {
      "raw": "{{baseUrl}}/accounts",
      "host": [
        "{{baseUrl}}"
      ],
      "path": [
        "accounts"
      ]
    },
    "description": "Create a sub account under a master account. Your account must be a master account in order to create sub accounts. \n<br><br>Zoom allows only [approved partners](https://marketplace.zoom.us/docs/api-reference/master-account-apis) to use master APIs and manage sub accounts. Email the partner programs team at partner-success@zoom.us. for more details. Please note that the created account user will receive a confirmation email.<br><br>\n<br>\n**Prerequisites:**<br>\n* Pro or a higher paid account with master account option enabled. <br>\n\n**Scope**: `account:write:admin`<br>\n**[Rate Limit Label](https://marketplace.zoom.us/docs/api-reference/rate-limits#rate-limits):** `Light`<br>\n\n\n "
  },
  "response": [
    {
      "name": "Account created.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "first_name",
              "value": "Ut",
              "description": "(Required) User's first name.",
              "type": "text"
            },
            {
              "key": "last_name",
              "value": "do mollit",
              "description": "(Required) User's last name.",
              "type": "text"
            },
            {
              "key": "email",
              "value": "esse Duis",
              "description": "(Required) User's email address.",
              "type": "text"
            },
            {
              "key": "password",
              "value": "Duis id elit dolor",
              "description": "(Required) User's password.\n\n**Note:** If the account owner or admin has enabled [enhanced password requirements](https://support.zoom.us/hc/en-us/articles/360034675592-Advanced-security-settings#h_fa9186e4-6818-4f7a-915c-2e25c19f0acd), the value provided in this field must meet those requirements. These requirements can be retrieved by calling the [Get Account Settings API](https://marketplace.zoom.us/docs/api-reference/zoom-api/accounts/accountsettings) and referring to the `password_requirement` field present in the `security` object.",
              "type": "text"
            },
            {
              "key": "options",
              "value": "{\"share_rc\":false,\"room_connector_list\":[\"ea dolore nisi magna\",\"in proident ut\"],\"share_mc\":false,\"meeting_connector_list\":[\"irure ad\",\"laborum\"],\"pay_mode\":\"master\",\"billing_auto_renew\":true}",
              "description": "Account options object.",
              "type": "text"
            },
            {
              "key": "account_name",
              "value": "aute sint ullamco",
              "description": "Name of the account. If you do not provide a value for this field, by default, the value will be set as a concatenation of \"first_name\" and \"last_name\". ",
              "type": "text"
            },
            {
              "key": "sub_reseller_id",
              "value": "eiusmod labore aliquip",
              "description": "The sub-reseller's ID.\n\nIf you do not provide this field in the payload, a new subaccount will be created for the requested account.",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/accounts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts"
          ]
        }
      },
      "status": "Created",
      "code": 201,
      "_postman_previewlanguage": "json",
      "header": [
        {
          "key": "Content-Location",
          "value": "quis officia in reprehenderit",
          "description": "Location of the created account."
        },
        {
          "key": "Content-Type",
          "value": "application/json"
        }
      ],
      "cookie": [
      ],
      "body": "{\n \"id\": \"string\",\n \"owner_id\": \"string\",\n \"owner_email\": \"string\",\n \"created_at\": \"string\"\n}"
    },
    {
      "name": "**HTTP Status Code:** `400`<br>\n**Error Code:**`300`<br> Your request could not be completed because the name contains an invalid word: {name}<br> Your request was not accepted because \"{field}\" contains special character(s).\n**Error Code:** `1107`<br>\nEm",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "first_name",
              "value": "Ut",
              "description": "(Required) User's first name.",
              "type": "text"
            },
            {
              "key": "last_name",
              "value": "do mollit",
              "description": "(Required) User's last name.",
              "type": "text"
            },
            {
              "key": "email",
              "value": "esse Duis",
              "description": "(Required) User's email address.",
              "type": "text"
            },
            {
              "key": "password",
              "value": "Duis id elit dolor",
              "description": "(Required) User's password.\n\n**Note:** If the account owner or admin has enabled [enhanced password requirements](https://support.zoom.us/hc/en-us/articles/360034675592-Advanced-security-settings#h_fa9186e4-6818-4f7a-915c-2e25c19f0acd), the value provided in this field must meet those requirements. These requirements can be retrieved by calling the [Get Account Settings API](https://marketplace.zoom.us/docs/api-reference/zoom-api/accounts/accountsettings) and referring to the `password_requirement` field present in the `security` object.",
              "type": "text"
            },
            {
              "key": "options",
              "value": "{\"share_rc\":false,\"room_connector_list\":[\"ea dolore nisi magna\",\"in proident ut\"],\"share_mc\":false,\"meeting_connector_list\":[\"irure ad\",\"laborum\"],\"pay_mode\":\"master\",\"billing_auto_renew\":true}",
              "description": "Account options object.",
              "type": "text"
            },
            {
              "key": "account_name",
              "value": "aute sint ullamco",
              "description": "Name of the account. If you do not provide a value for this field, by default, the value will be set as a concatenation of \"first_name\" and \"last_name\". ",
              "type": "text"
            },
            {
              "key": "sub_reseller_id",
              "value": "eiusmod labore aliquip",
              "description": "The sub-reseller's ID.\n\nIf you do not provide this field in the payload, a new subaccount will be created for the requested account.",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/accounts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts"
          ]
        }
      },
      "status": "Bad Request",
      "code": 400,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    },
    {
      "name": "**HTTP Status Code:** `409`<br>\n**Error Code:** `1005`<br>\nEmail $email has already been used.",
      "originalRequest": {
        "method": "POST",
        "header": [
          {
            "description": "Added as a part of security scheme: oauth2",
            "key": "Authorization",
            "value": "<token>"
          }
        ],
        "body": {
          "mode": "formdata",
          "formdata": [
            {
              "key": "first_name",
              "value": "Ut",
              "description": "(Required) User's first name.",
              "type": "text"
            },
            {
              "key": "last_name",
              "value": "do mollit",
              "description": "(Required) User's last name.",
              "type": "text"
            },
            {
              "key": "email",
              "value": "esse Duis",
              "description": "(Required) User's email address.",
              "type": "text"
            },
            {
              "key": "password",
              "value": "Duis id elit dolor",
              "description": "(Required) User's password.\n\n**Note:** If the account owner or admin has enabled [enhanced password requirements](https://support.zoom.us/hc/en-us/articles/360034675592-Advanced-security-settings#h_fa9186e4-6818-4f7a-915c-2e25c19f0acd), the value provided in this field must meet those requirements. These requirements can be retrieved by calling the [Get Account Settings API](https://marketplace.zoom.us/docs/api-reference/zoom-api/accounts/accountsettings) and referring to the `password_requirement` field present in the `security` object.",
              "type": "text"
            },
            {
              "key": "options",
              "value": "{\"share_rc\":false,\"room_connector_list\":[\"ea dolore nisi magna\",\"in proident ut\"],\"share_mc\":false,\"meeting_connector_list\":[\"irure ad\",\"laborum\"],\"pay_mode\":\"master\",\"billing_auto_renew\":true}",
              "description": "Account options object.",
              "type": "text"
            },
            {
              "key": "account_name",
              "value": "aute sint ullamco",
              "description": "Name of the account. If you do not provide a value for this field, by default, the value will be set as a concatenation of \"first_name\" and \"last_name\". ",
              "type": "text"
            },
            {
              "key": "sub_reseller_id",
              "value": "eiusmod labore aliquip",
              "description": "The sub-reseller's ID.\n\nIf you do not provide this field in the payload, a new subaccount will be created for the requested account.",
              "type": "text"
            }
          ]
        },
        "url": {
          "raw": "{{baseUrl}}/accounts",
          "host": [
            "{{baseUrl}}"
          ],
          "path": [
            "accounts"
          ]
        }
      },
      "status": "Conflict",
      "code": 409,
      "_postman_previewlanguage": "text",
      "header": [
        {
          "key": "Content-Type",
          "value": "text/plain"
        }
      ],
      "cookie": [
      ],
      "body": ""
    }
  ]
}