Skip to main content
POST
/
organization
Create Organization
curl --request POST \
  --url https://apiweb.mile.app/api/v3/organization \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "organizationName": "My New Company",
  "hubName": "Main Warehouse",
  "hubLat": -6.2088,
  "hubLng": 106.8456,
  "copyDataFromFirstOrg": false
}
'
{
  "status": true,
  "message": "Organization created successfully",
  "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9...",
  "expires_in": 31536000,
  "data": {
    "_id": "507f1f77bcf86cd799439099",
    "name": "John Doe",
    "email": "john@example.com",
    "organizationId": "507f1f77bcf86cd799439100",
    "hubId": [
      "507f1f77bcf86cd799439102"
    ]
  },
  "isHubSet": true,
  "organizations": [
    {
      "userId": "507f1f77bcf86cd799439011",
      "organizationId": "507f1f77bcf86cd799439022",
      "organizationName": "Acme Corp",
      "organizationLogo": null,
      "roleName": "owner",
      "isCurrent": false
    },
    {
      "userId": "507f1f77bcf86cd799439099",
      "organizationId": "507f1f77bcf86cd799439100",
      "organizationName": "My New Company",
      "organizationLogo": null,
      "roleName": "owner",
      "isCurrent": true
    }
  ]
}

Authorizations

Authorization
string
header
required

Use a valid Bearer token to authenticate.

Body

application/json
organizationName
string
required

Name for the new organization

Required string length: 3 - 100
hubName
string

Hub name. Required if user has no existing owned organization with hubs.

Maximum string length: 100
hubLat
number

Hub latitude. Required if user has no existing owned organization with hubs.

Required range: -90 <= x <= 90
hubLng
number

Hub longitude. Required if user has no existing owned organization with hubs.

Required range: -180 <= x <= 180
copyDataFromFirstOrg
boolean
default:false

Whether to copy data from user's first organization where they have 'owner' role. When enabled, copies: (1) Organization configuration (language, currency, settings), (2) All hubs the user has access to, (3) Custom roles with system permissions only (custom module permissions are excluded), (4) All flows. Note: Default roles (owner, admin, planner, field user) always use standard templates regardless of this setting.

Response

Organization created successfully - returns new access token and user data

status
boolean

Operation success status

message
string

Success message

token
string

New access token for the created organization

expires_in
integer

Token expiration time in seconds

data
object

User data for the new organization

isHubSet
boolean

Always true for new organizations

organizations
object[]

Updated list of all user's organizations