# Invite User To Workspace

<Heading
  as={"h1"}
  className={"openapi__heading"}
  children={"Invite User To Workspace"}
>
</Heading>

<MethodEndpoint
  method={"post"}
  path={"/api/v1/workspaces/{workspace_name}/invitation"}
  context={"endpoint"}
>
  
</MethodEndpoint>

Invites a user directly to a specific workspace with the specified role.

This endpoint allows workspace administrators to invite users directly to their workspace,
bypassing the organization-level invitation process. The user will be:

1. Created in the Haystack Enterprise Platform if they don't already exist
2. Added to the organization if they're not already a member
3. Assigned the specified role within the target workspace

**Required Permissions:** WORKSPACE_MEMBERS write permission on the target workspace.

**Valid preset roles are:** ADMIN, EDITOR

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

<ParamsDetails
  parameters={[{"description":"Type the name of the workspace.","in":"path","name":"workspace_name","required":true,"schema":{"description":"Type the name of the workspace.","title":"Workspace Name","type":"string"}}]}
>
  
</ParamsDetails>

<RequestSchema
  title={"Body"}
  body={{"content":{"application/json":{"schema":{"description":"Request model for inviting users directly to a workspace.\nThis model is used to invite users to a specific workspace with a designated role.\nThe user will be added to the organization if they don't already exist, and then\nassigned the specified role within the target workspace.","example":{"email":"user@example.com","family_name":"Doe","given_name":"John","role":"EDITOR"},"properties":{"email":{"description":"Email of a user.","title":"Email","type":"string"},"family_name":{"description":"Family name of a user.","title":"Family name","type":"string"},"given_name":{"description":"Given name of a user.","title":"Given name","type":"string"},"role":{"description":"Role of the user. This can be a custom role or one of the default roles.","title":"User Role","type":"string"}},"required":["given_name","family_name","email","role"],"title":"Workspace User Invitation","type":"object"}}},"required":true}}
>
  
</RequestSchema>

<StatusCodes
  id={undefined}
  label={undefined}
  responses={{"201":{"content":{"application/json":{"schema":{}}},"description":"User invited to workspace."},"402":{"description":"Inviting users is not available on the free plan. To invite team members, please upgrade to a paid plan."},"409":{"description":"The user already belongs to the organization."},"422":{"content":{"application/json":{"schema":{"properties":{"detail":{"items":{"properties":{"ctx":{"title":"Context","type":"object"},"input":{"title":"Input"},"loc":{"items":{"anyOf":[{"type":"string"},{"type":"integer"}]},"title":"Location","type":"array"},"msg":{"title":"Message","type":"string"},"type":{"title":"Error Type","type":"string"}},"required":["loc","msg","type"],"title":"ValidationError","type":"object"},"title":"Detail","type":"array"}},"title":"HTTPValidationError","type":"object"}}},"description":"Validation Error"},"503":{"description":"Something went wrong during signup."}}}
>
  
</StatusCodes>
