---
id: user-grants-bulk-create
title: Bulk create grants for a user
description: >-
  Create multiple grants for a user in a single request. This operation is
  **additive**: it adds new grants without affecting existing ones.
sidebar_label: Bulk create grants for a user
hide_title: true
hide_table_of_contents: true
api: >-
  eJztWm1v2zgS/isEv2ybUxynbS6tgD3ATdKt99qmcJzrHtIgpqWxxY1EqiQVx2v4vx9mKNmS7Lz0ervbAzZfIkvizHBennlIasFjsJGRuZNa8ZAfGRAOWFakTuYpsKkRylk20YYJVlgwTCommJVqmgIz8KUA6zpsmEjLdA5GoBwmLdvZEXEsnbyBnZ2QScdEHFumYFaJnEmX6MIxMZlA5KSaMriVli60Atv5rD6rYQJtqc4IZUWEN0RKoidMqLmXyiZCppbdiFTGNCZgSlcKhQEW0fRiEv5vXbBIKLazU1hgIF0Cho2MTuFKxiOmqx82LaajnR3yAYgoKVVJxVyydsFnxQPuxNTy8IIPdApMqNi/yi8DvppFP+YhR0eG3qxwXKTXu94uHnALUWGkm/PwYsHHIAyYXuESHl5cLi8DngsjMnBgLL2gRAY85DLmAZcYvly4hAetmKIXCyW/FMBkDMrJiQRD08EJUFANRCBv0Pd4y1vW4QHH2UkDMQ+dKSDgNkogEzxccDfPSbVyMAXDlwGHW5HlKfDw8OUrtLX0zGsdz3FApJUD5fBS5HkqI3LH3q8WbVxsShbGiPnGXHp4l+lJFVSny5g25tNhJ+tAZYV1zOYQycmcCcU+DD5QbMqIiztj7mOaSdV3kFke7gc8E7fVj2434NJfL7hWcDqhkDjp0Af8HEuEoTCGwjA5/Lz0+FeIXMO3F1wZVLVSjRmTG8wZJ4EU4Atr31hnpJpuDTTOTk/K1LS6MBGwWQIG/C20R1omrJVTBTHGeBU3rs1UKPkbBebH/VBEkS6U+/EZRndt26PMwDdXdqBSp0ulVHv/YB+0g5CdAbALrBZ7+WQv1pHdE4VLtCmN2MOh9inFNtMGmFQT7cOytjqGG0jRV3y5XAZbI9A/frz/Zfy9el/GWwpvmxX94z/G9Yfd7vP9w8ODvy+Xy8tlsPI8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KBWzvnJl0u8bbn0OHFJTJZIz1SXix4LC1exzyciNS2Iaoe0CeDsrk/Zd/wdcXWiVXLK4WLq5Jocx7wa5j7Tz3oqDABEYMhq/2DI2/b7tAzjWrgxhYz1pAf0YsiyN29717WoOfj6dkQi738nCOjHsiNmGHNiZk3UpOvCEPo3oKnQk0L6gncy0RoEE1kaSGJ/45imxsWC//GUF+DWi5XXnH4m9M55X8Atl/StA==
sidebar_class_name: post api-method
info_path: docs/api/authorization
custom_edit_url: null
canonical: 'https://docs.nullplatform.com/docs/api/user-grants-bulk-create'
---
<Heading
  as={"h1"}
  className={"openapi__heading"}
  children={"Bulk create grants for a user"}
>
</Heading>

<MethodEndpoint
  method={"post"}
  path={"/user/{id}/grant"}
  context={"endpoint"}
>

</MethodEndpoint>

Create multiple grants for a user in a single request. This operation is **additive**: it adds new grants without affecting existing ones.

The operation is **transactional**: if any grant fails validation, no grants are created.

You can **use either `role_id` or `role_slug`** for each grant in the request.

<Heading
  id={"request"}
  as={"h2"}
  className={"openapi-tabs__heading"}
  children={"Request"}
>
</Heading>

<ParamsDetails
  parameters={[{"name":"id","in":"path","description":"The unique identifier for the user receiving the grants.","required":true,"schema":{"type":"integer"},"example":789}]}
>

</ParamsDetails>

<RequestSchema
  title={"Body"}
  body={{"content":{"application/json":{"schema":{"type":"array","description":"Array of grants to create for the user. Each grant must specify an NRN and either a `role_id` or `role_slug`.\n","minItems":1,"maxItems":100,"items":{"oneOf":[{"title":"Using role slug","type":"object","required":["nrn","role_slug"],"properties":{"nrn":{"type":"string","description":"The NRN of the resource where the role is assigned.","example":"organization=1:account=2"},"role_slug":{"type":"string","description":"The slug of the role to assign.\n\n> Note: See [Roles](/docs/authorization/roles) for more info.\n","example":"developer"}}},{"title":"Using role ID","type":"object","required":["nrn","role_id"],"properties":{"nrn":{"type":"string","description":"The NRN of the resource where the role is assigned.","example":"organization=1:account=2"},"role_id":{"type":"integer","description":"The ID of the role to assign.\n\n> Note: See [Roles](/docs/authorization/roles) for more info.\n","example":700317756}}}]},"title":"bulkGrantRequest"},"examples":{"Using role_slug":{"value":[{"nrn":"organization=1:account=2","role_slug":"developer"},{"nrn":"organization=1:account=3","role_slug":"ops"}]},"Using role_id":{"value":[{"nrn":"organization=1:account=2","role_id":700317756},{"nrn":"organization=1:account=3","role_id":708509758}]},"Mixed role_id and role_slug":{"value":[{"nrn":"organization=1:account=2","role_slug":"developer"},{"nrn":"organization=1:account=3","role_id":708509758}]}}}}}}
>

</RequestSchema>

<StatusCodes
  id={undefined}
  label={undefined}
  responses={{"201":{"description":"All grants were created successfully.","content":{"application/json":{"schema":{"type":"array","description":"Array of created/updated grants.","items":{"type":"object","required":["id","nrn","user_id","role_id","status"],"properties":{"id":{"type":"integer","description":"The unique identifier for the grant.","example":12345},"nrn":{"type":"string","description":"The NRN of the resource where the role is assigned.","example":"organization=1:account=2"},"user_id":{"type":"integer","description":"The ID of the user who received the grant.","example":789},"role_id":{"type":"integer","description":"The ID of the role assigned.","example":700317756},"role_slug":{"type":"string","description":"The slug of the role assigned.","example":"developer"},"status":{"type":"string","enum":["active","pending"],"description":"The status of the grant.","example":"active"}},"title":"bulkGrantResponse"},"title":"bulkGrantArrayResponse"}}}},"400":{"description":"The request failed validation. Common causes:\n- A grant already exists for this user with the same NRN and role\n- The role does not exist\n- The role has an assignment restriction incompatible with the user type\n- The requesting user is not authorized to assign the specified role\n\nThe `cause.index` field indicates which grant in the array failed.\n","content":{"application/json":{"schema":{"type":"object","required":["statusCode","code","error","message"],"properties":{"statusCode":{"type":"integer","description":"HTTP status code.","example":400},"code":{"type":"string","description":"Machine-readable error code.","example":"RESOURCE_GRANTS.BULK_CREATE_FAILED"},"error":{"type":"string","description":"Human-readable error type.","example":"Bad Request"},"message":{"type":"string","description":"Details about the error.","example":"Failed to create grants in bulk"},"cause":{"type":"object","description":"Details about the specific grant that failed.","properties":{"code":{"type":"string","description":"The specific error code for the failed grant.","example":"RESOURCE_GRANTS.DUPLICATE_GRANT"},"detail":{"type":"string","description":"Details about why this grant failed.","example":"The grant already exists"},"index":{"type":"integer","description":"The zero-based index of the grant that failed in the request array.","example":1}}}},"title":"bulkGrantError"}}}},"4XX":{"description":"The request couldn't be processed. For example, a parameter is invalid, the resource doesn't exist, or you don't have permission. The body is a problem details object (RFC 9457).","content":{"application/problem+json":{"schema":{"type":"object","description":"Describes what went wrong, following the RFC 9457 problem details format.","required":["type","title","status"],"properties":{"type":{"type":"string","description":"A URI that identifies the kind of problem. It's an identifier, not a link, and it's the same every time this problem occurs.","example":"urn:nullplatform:error:routes-helper:invalid-params"},"title":{"type":"string","description":"A short, human-readable summary of the problem.","example":"There are invalid parameters on the request"},"status":{"type":"integer","description":"The HTTP status code of the response.","example":400},"code":{"type":"string","description":"A stable, machine-readable error code. Use it to handle specific errors in your integrations.","example":"ROUTES_HELPER.INVALID_PARAMS"},"detail":{"type":"string","nullable":true,"description":"More information about what went wrong in this request, when available.","example":null},"errors":{"type":"array","description":"One entry per invalid field or parameter. Only present on validation errors.","items":{"type":"object","properties":{"field":{"type":"string","description":"The name of the invalid field or parameter.","example":"application_id"},"in":{"type":"string","description":"Where the field was sent: `body`, `query`, or `params` (path parameters).","example":"query"},"issue":{"type":"string","description":"What's wrong with the field, such as `required` or `invalid`.","example":"invalid"},"value":{"description":"The value that was sent, when relevant.","example":"not-a-number"},"message":{"type":"string","description":"A human-readable explanation of the issue."}}}},"message":{"type":"string","deprecated":true,"description":"Same value as `title`, kept for backward compatibility. Use `title` or `code` instead.","example":"There are invalid parameters on the request"},"traceId":{"type":"string","description":"An identifier for this request, when available. Include it when you contact nullplatform support."}}}}}},"5XX":{"description":"Something went wrong on nullplatform's side. The body is a problem details object (RFC 9457).","content":{"application/problem+json":{"schema":{"type":"object","description":"Describes what went wrong, following the RFC 9457 problem details format.","required":["type","title","status"],"properties":{"type":{"type":"string","description":"A URI that identifies the kind of problem. It's an identifier, not a link, and it's the same every time this problem occurs.","example":"about:blank"},"title":{"type":"string","description":"A short, human-readable summary of the problem.","example":"Oops.. there was an internal error"},"status":{"type":"integer","description":"The HTTP status code of the response.","example":500},"code":{"type":"string","description":"A stable, machine-readable error code. Use it to handle specific errors in your integrations."},"detail":{"type":"string","nullable":true,"description":"More information about what went wrong in this request, when available.","example":null},"message":{"type":"string","deprecated":true,"description":"Same value as `title`, kept for backward compatibility. Use `title` or `code` instead.","example":"Oops.. there was an internal error"},"traceId":{"type":"string","description":"An identifier for this request, when available. Include it when you contact nullplatform support."}}}}}}}}
>

</StatusCodes>

