create_unit

To create a new unit, use the core/create_unit method.

Copied!
svc=core/create_unit&params={
  "creatorId": <long>,
  "name": "<text>",
  "hwTypeId": <long>,
  "dataFlags": <long>
}

Parameters

Parameter Description
creatorId The ID of the user that should be the unit creator.
name Unit name (4–50 characters).
hwTypeId Device type ID.
dataFlags Flags with the unit properties for the response (see Units).

Response

If the request is completed successfully, the response is returned in the following format:

Copied!
{
  "item": {         /* Created unit. */
    ...
  },
  "flags": <uint>   /* Applied flags with properties. */
}

The format of the item parameter is described on the Units page.

If the request fails, an error code is returned.

Error codes

Error code Description
4 Wrong input parameters, or failed to fetch the device type by ID.
6 One of the following errors:
  • Failed to fetch the creator, or you have no Act on behalf of this user access right to the creator.
  • The current user doesn’t have the Can create items flag (0x04).
  • Failed to create the unit.
7 The creator belongs to a top account, or the create_units billing transaction failed.

If you find a mistake in the text, please select it and press Ctrl+Enter.