Invite User to Organization - m3ter Documentation
Invite User to Organization
cURL
curl --request POST \
--url https://api.m3ter.com/organizations/{orgId}/invitations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"firstName": "<string>",
"lastName": "<string>",
"email": "jsmith@example.com",
"m3terUser": true,
"version": 123,
"contactNumber": "<string>",
"permissionPolicyIds": [\
"<string>"\
],
"dtEndAccess": "2023-11-07T05:31:56Z",
"dtExpiry": "2023-11-07T05:31:56Z"
}
'
Python
import requests
url = "https://api.m3ter.com/organizations/{orgId}/invitations"
payload = {
"firstName": "<string>",
"lastName": "<string>",
"email": "jsmith@example.com",
"m3terUser": True,
"version": 123,
"contactNumber": "<string>",
"permissionPolicyIds": ["<string>"],
"dtEndAccess": "2023-11-07T05:31:56Z",
"dtExpiry": "2023-11-07T05:31:56Z"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)
JavaScript (Fetch)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
firstName: '<string>',
lastName: '<string>',
email: 'jsmith@example.com',
m3terUser: true,
version: 123,
contactNumber: '<string>',
permissionPolicyIds: ['<string>'],
dtEndAccess: '2023-11-07T05:31:56Z',
dtExpiry: '2023-11-07T05:31:56Z'
})
};
fetch('https://api.m3ter.com/organizations/{orgId}/invitations', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));
PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [\
CURLOPT_URL => "https://api.m3ter.com/organizations/{orgId}/invitations",\
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([\
'firstName' => '<string>',\
'lastName' => '<string>',\
'email' => 'jsmith@example.com',\
'm3terUser' => true,\
'version' => 123,\
'contactNumber' => '<string>',\
'permissionPolicyIds' => [\
'<string>'\
],\
'dtEndAccess' => '2023-11-07T05:31:56Z',\
'dtExpiry' => '2023-11-07T05:31:56Z'\
]),\
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;
}
?>
Go
package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.m3ter.com/organizations/{orgId}/invitations"
payload := strings.NewReader("{\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"email\": \"jsmith@example.com\",\n \"m3terUser\": true,\n \"version\": 123,\n \"contactNumber\": \"<string>\",\n \"permissionPolicyIds\": [\n \"<string>\"\n ],\n \"dtEndAccess\": \"2023-11-07T05:31:56Z\",\n \"dtExpiry\": \"2023-11-07T05:31:56Z\"}")
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))
}
Unirest (Java)
HttpResponse<String> response = Unirest.post("https://api.m3ter.com/organizations/{orgId}/invitations")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"email\": \"jsmith@example.com\",\n \"m3terUser\": true,\n \"version\": 123,\n \"contactNumber\": \"<string>\",\n \"permissionPolicyIds\": [\n \"<string>\"\n ],\n \"dtEndAccess\": \"2023-11-07T05:31:56Z\",\n \"dtExpiry\": \"2023-11-07T05:31:56Z\"}")
.asString();
Ruby
require 'uri'
require 'net/http'
url = URI("https://api.m3ter.com/organizations/{orgId}/invitations")
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 \"firstName\": \"<string>\",\n \"lastName\": \"<string>\",\n \"email\": \"jsmith@example.com\",\n \"m3terUser\": true,\n \"version\": 123,\n \"contactNumber\": \"<string>\",\n \"permissionPolicyIds\": [\n \"<string>\"\n ],\n \"dtEndAccess\": \"2023-11-07T05:31:56Z\",\n \"dtExpiry\": \"2023-11-07T05:31:56Z\"}"
response = http.request(request)
puts response.read_body
Response Codes
- 200: Invitation successfully created.
- 4XX: Client error.
- 5XX: Server error.
Response Example
{
"id": "<string>",
"version": 123,
"email": "<string>",
"permissionPolicyIds": ["<string>"],
"firstName": "<string>",
"lastName": "<string>",
"dtEndAccess": "2023-11-07T05:31:56Z",
"dtExpiry": "2023-11-07T05:31:56Z",
"invitingPrincipalId": "<string>",
"accepted": true,
"dtCreated": "2023-11-07T05:31:56Z",
"dtLastModified": "2023-11-07T05:31:56Z",
"createdBy": "<string>",
"lastModifiedBy": "<string>"
}
Body Parameters
firstName: Required string length: 1 - 100
lastName: Required string length: 1 - 100
email: Email must be valid.
m3terUser: Boolean indicating if the user is a m3ter user.
version: Integer, version number of the invitation.
contactNumber: Maximum length 50.
permissionPolicyIds: Array of permission policy IDs.
dtEndAccess: Date when access will end.
dtExpiry: Date when the invite expires.
Authorization
- Use
Bearer token for authentication.