> For AI agents: [llms.txt](https://docs.trustedauth.com/llms.txt) provides a Markdown index of this documentation.

# Create and get the Magic Link for a user

`PUT /api/web/v1/users/{userid}/magiclink`

Create and get the Magic Link for the specified user UUID. Requires the MAGICLINKS:ADD permission.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| userid | path | Yes | string |  |

## Request Body

Required.

### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "autoSend": {
      "type": "boolean",
      "description": "Automatically send the Magic Link if the user has a default email or one is specified that matches a configured email.",
      "example": true
    },
    "email": {
      "type": "string",
      "description": "The email to send the Magic Link to if it exists.",
      "example": "support@mycompany.com"
    },
    "redirectUrl": {
      "type": "string",
      "description": "Automatically redirect the user to an external URL after completing registration or password reset. The URL must match one of the allowed URLs.",
      "example": "https://mycompany.com"
    },
    "type": {
      "type": "string",
      "description": "The type of magic link to create. If not specified, defaults to REGISTRATION.",
      "example": "REGISTRATION/PASSWORD_RESET"
    }
  },
  "description": "Magic link Parameters for a user.",
  "title": "MagicLinkCreateParms"
}
```

## Responses

### 200

Successful

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "expiryDate": {
      "type": "string",
      "description": "Expiry date of the Magic Link.",
      "format": "date-time",
      "example": "2023-01-01T12:12:12Z"
    },
    "url": {
      "type": "string",
      "description": "The generated Magic Link. This value will only be returned if the administrator has the MAGICLINKCONTENTS:VIEW permission and autoSend is set to false.",
      "example": "https://mycompany.com/#/?magicToken=1a2b3c4d5e6f7g8h9i"
    }
  },
  "description": "Parameters returned from the create Magic Link operation.",
  "title": "MagicLinkResponse"
}
```

### 400

Bad Request

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 401

Access denied

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 403

Forbidden

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 404

Not Found

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

### 409

Conflict

#### application/json

Schema

```json
{
  "type": "object",
  "properties": {
    "errorCode": {
      "type": "string",
      "description": "Error Codes specific to cause of failure.",
      "example": "invalid_user_response"
    },
    "errorMessage": {
      "type": "string",
      "description": "Additional Error Message describing the error.",
      "example": "Application id cannot be null"
    },
    "parameters": {
      "type": "array",
      "description": "Optional additional error information.",
      "items": {
        "type": "object",
        "description": "Optional additional error information."
      }
    }
  },
  "description": "Object containing information about errors reported by services.",
  "title": "ErrorInfo"
}
```

## Security

Requirements

```json
[
  {
    "AdminAPIAuthentication": [
      "MAGICLINKS:ADD"
    ]
  }
]
```
