> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://support.atomicwork.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://support.atomicwork.com/_mcp/server.

# Create a grant for a user

POST https://{tenant}.atomicwork.com/api/v1/iga/grants
Content-Type: application/json

Create an identity grant directly without going through the IGA workflow.
Requires user_id and entitlement_id. Optionally specify policy, granted_by, and granted_at.
The grant method is automatically derived from the entitlement's provisioning config.


Reference: https://support.atomicwork.com/api-reference/atomicwork-public-api/access-management/postapi-v-1-iga-grants

## Authentication

- `X-Api-Key` header (required) — API Key authentication via header

## Request

### Headers

- `X-Workspace-Id` (string, optional)

### Body (application/json)

This endpoint expects an object.

- `user_id` (long, required) — The ID of the user who will receive the grant
- `entitlement_id` (long, required) — The ID of the entitlement to grant
- `policy_id` (long, optional) — Optional policy ID to associate with the grant
- `policy_key` (string, optional) — Optional policy key (alternative to policy_id)
- `granted_by` (long, optional) — Optional user ID of who authorized this grant. Defaults to the API key owner.
- `granted_at` (datetime, optional) — Optional timestamp of when the grant was authorized. Defaults to current time.

## Response

### 200

Successful response

## Examples

**Request**

```json
{
  "user_id": 0,
  "entitlement_id": 0,
  "policy_id": 0,
  "policy_key": "",
  "granted_by": 0,
  "granted_at": "2024-01-01T00:00:00Z"
}
```

**Response**

```json
{}
```

**SDK Code**

```python Access Management_postapi_v1_iga_grants_example
import requests

url = "https://{tenant}.atomicwork.com/api/v1/iga/grants"

payload = {
    "user_id": 0,
    "entitlement_id": 0,
    "policy_id": 0,
    "policy_key": "",
    "granted_by": 0,
    "granted_at": "2024-01-01T00:00:00Z"
}
headers = {
    "X-Workspace-Id": "{{workspace_id}}",
    "X-Api-Key": "<apiKey>",
    "Content-Type": "application/json"
}

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

print(response.json())
```

```javascript Access Management_postapi_v1_iga_grants_example
const url = 'https://{tenant}.atomicwork.com/api/v1/iga/grants';
const options = {
  method: 'POST',
  headers: {
    'X-Workspace-Id': '{{workspace_id}}',
    'X-Api-Key': '<apiKey>',
    'Content-Type': 'application/json'
  },
  body: '{"user_id":0,"entitlement_id":0,"policy_id":0,"policy_key":"","granted_by":0,"granted_at":"2024-01-01T00:00:00Z"}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go Access Management_postapi_v1_iga_grants_example
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://{tenant}.atomicwork.com/api/v1/iga/grants"

	payload := strings.NewReader("{\n  \"user_id\": 0,\n  \"entitlement_id\": 0,\n  \"policy_id\": 0,\n  \"policy_key\": \"\",\n  \"granted_by\": 0,\n  \"granted_at\": \"2024-01-01T00:00:00Z\"\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-Workspace-Id", "{{workspace_id}}")
	req.Header.Add("X-Api-Key", "<apiKey>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby Access Management_postapi_v1_iga_grants_example
require 'uri'
require 'net/http'

url = URI("https://{tenant}.atomicwork.com/api/v1/iga/grants")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-Workspace-Id"] = '{{workspace_id}}'
request["X-Api-Key"] = '<apiKey>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"user_id\": 0,\n  \"entitlement_id\": 0,\n  \"policy_id\": 0,\n  \"policy_key\": \"\",\n  \"granted_by\": 0,\n  \"granted_at\": \"2024-01-01T00:00:00Z\"\n}"

response = http.request(request)
puts response.read_body
```

```java Access Management_postapi_v1_iga_grants_example
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.post("https://{tenant}.atomicwork.com/api/v1/iga/grants")
  .header("X-Workspace-Id", "{{workspace_id}}")
  .header("X-Api-Key", "<apiKey>")
  .header("Content-Type", "application/json")
  .body("{\n  \"user_id\": 0,\n  \"entitlement_id\": 0,\n  \"policy_id\": 0,\n  \"policy_key\": \"\",\n  \"granted_by\": 0,\n  \"granted_at\": \"2024-01-01T00:00:00Z\"\n}")
  .asString();
```

```php Access Management_postapi_v1_iga_grants_example
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('POST', 'https://{tenant}.atomicwork.com/api/v1/iga/grants', [
  'body' => '{
  "user_id": 0,
  "entitlement_id": 0,
  "policy_id": 0,
  "policy_key": "",
  "granted_by": 0,
  "granted_at": "2024-01-01T00:00:00Z"
}',
  'headers' => [
    'Content-Type' => 'application/json',
    'X-Api-Key' => '<apiKey>',
    'X-Workspace-Id' => '{{workspace_id}}',
  ],
]);

echo $response->getBody();
```

```csharp Access Management_postapi_v1_iga_grants_example
using RestSharp;

var client = new RestClient("https://{tenant}.atomicwork.com/api/v1/iga/grants");
var request = new RestRequest(Method.POST);
request.AddHeader("X-Workspace-Id", "{{workspace_id}}");
request.AddHeader("X-Api-Key", "<apiKey>");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{\n  \"user_id\": 0,\n  \"entitlement_id\": 0,\n  \"policy_id\": 0,\n  \"policy_key\": \"\",\n  \"granted_by\": 0,\n  \"granted_at\": \"2024-01-01T00:00:00Z\"\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift Access Management_postapi_v1_iga_grants_example
import Foundation

let headers = [
  "X-Workspace-Id": "{{workspace_id}}",
  "X-Api-Key": "<apiKey>",
  "Content-Type": "application/json"
]
let parameters = [
  "user_id": 0,
  "entitlement_id": 0,
  "policy_id": 0,
  "policy_key": "",
  "granted_by": 0,
  "granted_at": "2024-01-01T00:00:00Z"
] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://{tenant}.atomicwork.com/api/v1/iga/grants")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```