Skip to main content

Create Batch API

This API is used to create a new batch in LMS.

Request URL: (Blended Learning Course)

https://people.zoho.com/api/v1/courses/<courseId>/batches/<batchId>?batchData={"name" :  <batchName>, "startDate" : <startDate>, "endDate" : <endDate>, "locations" : <locations>, "minimumCapacity" : <minimumCapacity>, "maximumCapacity":<maximumCapacity>, "allowWaitlisting" : <allowWaitlisting>, "cancelBatchWhenMinimumCapacityIsNotMet" : <cancelBatchWhenMinimumCapacityIsNotMet>, "waitingTimeForCancellation" : <waitingTimeForCancellation>, "waitingTimeUnitForCancellation" : <waitingTimeUnitForCancellation>}

Scope:

ZOHOPEOPLE.training.ALL
OR
ZOHOPEOPLE.training.CREATE

Possible Operation Types:

ALL - Complete access to data
CREATE - Only to create data

Method:

POST

Request Parameters

ParametersValues AllowedDefault ValueDescription
*batchData <parameters in JSON Object> JSON Input

 

ParametersValues AllowedDefault ValueDescription
*name<Batch name><Mandatory>Specify the batch name
*startDate<startDate date in DD-MM-YYYY format><Mandatory>Specify the start date
*endDate<endDate date in DD-MM-YYYY format><Mandatory>Specify the end date
minimumCapacityinteger values<Mandatory>Specify the minimum capacity
maximumCapacityinteger values<Mandatory>Specify the maximum capacity
locationsArray of location ids-Specify the location ids
allowWaitlistingtrue|false-Specify if wait-listing should be allowed or not
cancelBatchWhenMinimumCapacityIsNotMettrue|false--
waitingTimeForCancellationinteger values-Specify waiting time to cancel batch
waitingTimeUnitForCancellation"day"- 

*mandatory parameters

Error Codes and Descriptions

Status CodesDescription
400Invalid parameter value/input parameter missing
403Sorry! You are not authorized to do this operation
404Not found
422Maximum limit exceeded
500Sorry! Server error occured

View complete list of LMS API error codes

Threshold Limit: 30 requests | Lock period: 5 minutes

Threshold Limit - Number of API calls allowed within a minute.
Lock Period - Wait time before consecutive API requests.

Request

Copiedimport okhttp3.*;

public class Main {
    public static void main(String[] args) throws Exception {
        OkHttpClient client = new OkHttpClient();

        MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
        RequestBody body = RequestBody.create(mediaType, "batchData=%7B%22name%22%20%3A%20%22Add%20Batch%20API%20Testing%201%22%2C%20%22startDate%22%20%3A%20%2228-07-2021%22%2C%20%22endDate%22%20%3A%20%2229-07-2021%22%2C%20%22locations%22%20%3A%20%5B%5D%2C%20%22minimumCapacity%22%20%3A%202%2C%20%22maximumCapacity%22%3A20%2C%20%22allowWaitlisting%22%20%3A%20true%7D");

        Request request = new Request.Builder()
            .url("https://people.zoho.com/api/v1/courses/588882000001018001/batches")
            .post(body)
            .addHeader("Content-Type", "application/x-www-form-urlencoded")
            .addHeader("Authorization", "Zoho-oauthtoken YOUR_ACCESS_TOKEN")
            .build();

        Response response = client.newCall(request).execute();
        System.out.println(response.body().string());
    }
}
Copiedfetch("https://people.zoho.com/api/v1/courses/588882000001018001/batches", {
    method: "POST",
    headers: {
        "Content-Type": "application/x-www-form-urlencoded",
        "Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN"
    },
    body: "batchData=%7B%22name%22%20%3A%20%22Add%20Batch%20API%20Testing%201%22%2C%20%22startDate%22%20%3A%20%2228-07-2021%22%2C%20%22endDate%22%20%3A%20%2229-07-2021%22%2C%20%22locations%22%20%3A%20%5B%5D%2C%20%22minimumCapacity%22%20%3A%202%2C%20%22maximumCapacity%22%3A20%2C%20%22allowWaitlisting%22%20%3A%20true%7D"
})
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.error(error));
Copiedcurl --location --request POST 'https://people.zoho.com/api/v1/courses/588882000001018001/batches' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Zoho-oauthtoken YOUR_ACCESS_TOKEN' \
--data-urlencode 'batchData={"name":"Add Batch API Testing 1","startDate":"28-07-2021","endDate":"29-07-2021","locations":[],"minimumCapacity":2,"maximumCapacity":20,"allowWaitlisting":true}'
Copiedurl = "https://people.zoho.com/api/v1/courses/588882000001018001/batches";
headers = map();
headers.put("Content-Type", "application/x-www-form-urlencoded");
headers.put("Authorization", "Zoho-oauthtoken YOUR_ACCESS_TOKEN");

params = map();
params.put("batchData", "{\"name\":\"Add Batch API Testing 1\",\"startDate\":\"28-07-2021\",\"endDate\":\"29-07-2021\",\"locations\":[],\"minimumCapacity\":2,\"maximumCapacity\":20,\"allowWaitlisting\":true}");

response = invokeurl
[
    url : url
    type : POST
    parameters: params
    headers: headers
];

info response;
Copiedimport requests

url = "https://people.zoho.com/api/v1/courses/588882000001018001/batches"

payload = "batchData=%7B%22name%22%20%3A%20%22Add%20Batch%20API%20Testing%201%22%2C%20%22startDate%22%20%3A%20%2228-07-2021%22%2C%20%22endDate%22%20%3A%20%2229-07-2021%22%2C%20%22locations%22%20%3A%20%5B%5D%2C%20%22minimumCapacity%22%20%3A%202%2C%20%22maximumCapacity%22%3A20%2C%20%22allowWaitlisting%22%20%3A%20true%7D"

headers = {
    "Content-Type": "application/x-www-form-urlencoded",
    "Authorization": "Zoho-oauthtoken YOUR_ACCESS_TOKEN"
}

response = requests.post(url, headers=headers, data=payload)

print(response.text)

Header

CopiedAuthorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxx9be93.9b8xxxxxxf

Response

Copied{
    "code": "200",
    "batch": {
        "startDateAsDisplayString": "25-Dec-2021",
        "endDateAsDisplayString": "01-Feb-2022",
        "cancelBatchWhenMinimumCapacityIsNotMet": true,
        "waitingTimeUnitForCancellation": "day",
        "batchId": "219225000000653025",
        "waitingTimeForCancellation": 10,
        "learnersCount": 0,
        "name": "Batch One",
        "minimumCapacity": 2,
        "locations": [],
        "maximumCapacity": 20,
        "courseId": "219225000000645203",
        "publishStatus": "unpublished"
    },
    "message": "success"
}