curl --request POST \
--url https://apiweb.mile.app/api/v3/data-type/bulk \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data_types": [
{
"rec_index": 0,
"name": "OutletDetail",
"commonData": true,
"limitUser": false,
"fields": [
{
"id": "dataId",
"title": "Data ID",
"type": "string",
"required": true
},
{
"id": "outletName",
"title": "Outlet Name",
"type": "string",
"required": true
},
{
"id": "outletType",
"title": "Outlet Type",
"type": "string",
"optionData": [
"minimarket",
"supermarket"
],
"required": false
}
]
},
{
"rec_index": 1,
"name": "OutletDetail",
"fields": [
{
"id": "dataId",
"title": "Data ID",
"type": "string",
"required": true
}
]
}
]
}
'import requests
url = "https://apiweb.mile.app/api/v3/data-type/bulk"
payload = { "data_types": [
{
"rec_index": 0,
"name": "OutletDetail",
"commonData": True,
"limitUser": False,
"fields": [
{
"id": "dataId",
"title": "Data ID",
"type": "string",
"required": True
},
{
"id": "outletName",
"title": "Outlet Name",
"type": "string",
"required": True
},
{
"id": "outletType",
"title": "Outlet Type",
"type": "string",
"optionData": ["minimarket", "supermarket"],
"required": False
}
]
},
{
"rec_index": 1,
"name": "OutletDetail",
"fields": [
{
"id": "dataId",
"title": "Data ID",
"type": "string",
"required": True
}
]
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data_types: [
{
rec_index: 0,
name: 'OutletDetail',
commonData: true,
limitUser: false,
fields: [
{id: 'dataId', title: 'Data ID', type: 'string', required: true},
{id: 'outletName', title: 'Outlet Name', type: 'string', required: true},
{
id: 'outletType',
title: 'Outlet Type',
type: 'string',
optionData: ['minimarket', 'supermarket'],
required: false
}
]
},
{
rec_index: 1,
name: 'OutletDetail',
fields: [{id: 'dataId', title: 'Data ID', type: 'string', required: true}]
}
]
})
};
fetch('https://apiweb.mile.app/api/v3/data-type/bulk', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apiweb.mile.app/api/v3/data-type/bulk",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data_types' => [
[
'rec_index' => 0,
'name' => 'OutletDetail',
'commonData' => true,
'limitUser' => false,
'fields' => [
[
'id' => 'dataId',
'title' => 'Data ID',
'type' => 'string',
'required' => true
],
[
'id' => 'outletName',
'title' => 'Outlet Name',
'type' => 'string',
'required' => true
],
[
'id' => 'outletType',
'title' => 'Outlet Type',
'type' => 'string',
'optionData' => [
'minimarket',
'supermarket'
],
'required' => false
]
]
],
[
'rec_index' => 1,
'name' => 'OutletDetail',
'fields' => [
[
'id' => 'dataId',
'title' => 'Data ID',
'type' => 'string',
'required' => true
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apiweb.mile.app/api/v3/data-type/bulk"
payload := strings.NewReader("{\n \"data_types\": [\n {\n \"rec_index\": 0,\n \"name\": \"OutletDetail\",\n \"commonData\": true,\n \"limitUser\": false,\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletName\",\n \"title\": \"Outlet Name\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletType\",\n \"title\": \"Outlet Type\",\n \"type\": \"string\",\n \"optionData\": [\n \"minimarket\",\n \"supermarket\"\n ],\n \"required\": false\n }\n ]\n },\n {\n \"rec_index\": 1,\n \"name\": \"OutletDetail\",\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiweb.mile.app/api/v3/data-type/bulk")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data_types\": [\n {\n \"rec_index\": 0,\n \"name\": \"OutletDetail\",\n \"commonData\": true,\n \"limitUser\": false,\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletName\",\n \"title\": \"Outlet Name\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletType\",\n \"title\": \"Outlet Type\",\n \"type\": \"string\",\n \"optionData\": [\n \"minimarket\",\n \"supermarket\"\n ],\n \"required\": false\n }\n ]\n },\n {\n \"rec_index\": 1,\n \"name\": \"OutletDetail\",\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v3/data-type/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data_types\": [\n {\n \"rec_index\": 0,\n \"name\": \"OutletDetail\",\n \"commonData\": true,\n \"limitUser\": false,\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletName\",\n \"title\": \"Outlet Name\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletType\",\n \"title\": \"Outlet Type\",\n \"type\": \"string\",\n \"optionData\": [\n \"minimarket\",\n \"supermarket\"\n ],\n \"required\": false\n }\n ]\n },\n {\n \"rec_index\": 1,\n \"name\": \"OutletDetail\",\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": 1,
"failed": 1,
"data_types": [
{
"status": true,
"message": "Success",
"rec_index": 0,
"_id": "6710a3c2e4b0a1f2c3d4e5f6",
"name": "OutletDetail"
},
{
"status": false,
"message": "The name has already been taken.",
"rec_index": 1,
"name": "OutletDetail"
}
],
"failed_index": [
1
]
}{
"status": false,
"message": "Bad request - invalid parameters provided."
}{
"status": false,
"message": "Internal server error, please contact [email protected]."
}Create data types in bulk
Create up to 1000 data types in one request. Each item is validated and created on its own, so one invalid item does not stop the rest; the response lists the result of every item plus success and failed counts, and failed_index holds the rec_index of the items that failed.
Permission: view/dataType.
Available on /api/v3 and /api/v4. On /api/v4 the data types are created as v4 data types, which also accept the field types title, boolean, multiOption and relation, plus field unique, validations and relation settings.
curl --request POST \
--url https://apiweb.mile.app/api/v3/data-type/bulk \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"data_types": [
{
"rec_index": 0,
"name": "OutletDetail",
"commonData": true,
"limitUser": false,
"fields": [
{
"id": "dataId",
"title": "Data ID",
"type": "string",
"required": true
},
{
"id": "outletName",
"title": "Outlet Name",
"type": "string",
"required": true
},
{
"id": "outletType",
"title": "Outlet Type",
"type": "string",
"optionData": [
"minimarket",
"supermarket"
],
"required": false
}
]
},
{
"rec_index": 1,
"name": "OutletDetail",
"fields": [
{
"id": "dataId",
"title": "Data ID",
"type": "string",
"required": true
}
]
}
]
}
'import requests
url = "https://apiweb.mile.app/api/v3/data-type/bulk"
payload = { "data_types": [
{
"rec_index": 0,
"name": "OutletDetail",
"commonData": True,
"limitUser": False,
"fields": [
{
"id": "dataId",
"title": "Data ID",
"type": "string",
"required": True
},
{
"id": "outletName",
"title": "Outlet Name",
"type": "string",
"required": True
},
{
"id": "outletType",
"title": "Outlet Type",
"type": "string",
"optionData": ["minimarket", "supermarket"],
"required": False
}
]
},
{
"rec_index": 1,
"name": "OutletDetail",
"fields": [
{
"id": "dataId",
"title": "Data ID",
"type": "string",
"required": True
}
]
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
data_types: [
{
rec_index: 0,
name: 'OutletDetail',
commonData: true,
limitUser: false,
fields: [
{id: 'dataId', title: 'Data ID', type: 'string', required: true},
{id: 'outletName', title: 'Outlet Name', type: 'string', required: true},
{
id: 'outletType',
title: 'Outlet Type',
type: 'string',
optionData: ['minimarket', 'supermarket'],
required: false
}
]
},
{
rec_index: 1,
name: 'OutletDetail',
fields: [{id: 'dataId', title: 'Data ID', type: 'string', required: true}]
}
]
})
};
fetch('https://apiweb.mile.app/api/v3/data-type/bulk', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apiweb.mile.app/api/v3/data-type/bulk",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'data_types' => [
[
'rec_index' => 0,
'name' => 'OutletDetail',
'commonData' => true,
'limitUser' => false,
'fields' => [
[
'id' => 'dataId',
'title' => 'Data ID',
'type' => 'string',
'required' => true
],
[
'id' => 'outletName',
'title' => 'Outlet Name',
'type' => 'string',
'required' => true
],
[
'id' => 'outletType',
'title' => 'Outlet Type',
'type' => 'string',
'optionData' => [
'minimarket',
'supermarket'
],
'required' => false
]
]
],
[
'rec_index' => 1,
'name' => 'OutletDetail',
'fields' => [
[
'id' => 'dataId',
'title' => 'Data ID',
'type' => 'string',
'required' => true
]
]
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apiweb.mile.app/api/v3/data-type/bulk"
payload := strings.NewReader("{\n \"data_types\": [\n {\n \"rec_index\": 0,\n \"name\": \"OutletDetail\",\n \"commonData\": true,\n \"limitUser\": false,\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletName\",\n \"title\": \"Outlet Name\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletType\",\n \"title\": \"Outlet Type\",\n \"type\": \"string\",\n \"optionData\": [\n \"minimarket\",\n \"supermarket\"\n ],\n \"required\": false\n }\n ]\n },\n {\n \"rec_index\": 1,\n \"name\": \"OutletDetail\",\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n }\n ]\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apiweb.mile.app/api/v3/data-type/bulk")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"data_types\": [\n {\n \"rec_index\": 0,\n \"name\": \"OutletDetail\",\n \"commonData\": true,\n \"limitUser\": false,\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletName\",\n \"title\": \"Outlet Name\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletType\",\n \"title\": \"Outlet Type\",\n \"type\": \"string\",\n \"optionData\": [\n \"minimarket\",\n \"supermarket\"\n ],\n \"required\": false\n }\n ]\n },\n {\n \"rec_index\": 1,\n \"name\": \"OutletDetail\",\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n }\n ]\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apiweb.mile.app/api/v3/data-type/bulk")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"data_types\": [\n {\n \"rec_index\": 0,\n \"name\": \"OutletDetail\",\n \"commonData\": true,\n \"limitUser\": false,\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletName\",\n \"title\": \"Outlet Name\",\n \"type\": \"string\",\n \"required\": true\n },\n {\n \"id\": \"outletType\",\n \"title\": \"Outlet Type\",\n \"type\": \"string\",\n \"optionData\": [\n \"minimarket\",\n \"supermarket\"\n ],\n \"required\": false\n }\n ]\n },\n {\n \"rec_index\": 1,\n \"name\": \"OutletDetail\",\n \"fields\": [\n {\n \"id\": \"dataId\",\n \"title\": \"Data ID\",\n \"type\": \"string\",\n \"required\": true\n }\n ]\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"success": 1,
"failed": 1,
"data_types": [
{
"status": true,
"message": "Success",
"rec_index": 0,
"_id": "6710a3c2e4b0a1f2c3d4e5f6",
"name": "OutletDetail"
},
{
"status": false,
"message": "The name has already been taken.",
"rec_index": 1,
"name": "OutletDetail"
}
],
"failed_index": [
1
]
}{
"status": false,
"message": "Bad request - invalid parameters provided."
}{
"status": false,
"message": "Internal server error, please contact [email protected]."
}Authorizations
Use a valid Bearer token to authenticate.
Body
Data types to create, maximum 1000 per request. Each item uses the same body as Create data type: name (required, unique in the organization), fields (required), limitUser, commonData. Each field needs id (letters, digits, - and _ only), title, type and required; optionData is required for option fields.
Optional rec_index is echoed back so you can match results to your input.
1000Show child attributes
Show child attributes