---
title: "Data types"
toc_min_heading_level: 2
toc_max_heading_level: 3
---

# Data types

## TypeSpec.Http

### `AcceptedResponse` {#TypeSpec.Http.AcceptedResponse}

The request has been accepted for processing, but processing has not yet completed.

```typespec
model TypeSpec.Http.AcceptedResponse
```

### `ApiKeyAuth` {#TypeSpec.Http.ApiKeyAuth}

An API key is a token that a client provides when making API calls. The key can be sent in the query string:

```
GET /something?api_key=abcdef12345
```

or as a request header

```
GET /something HTTP/1.1
X-API-Key: abcdef12345
```

or as a cookie

```
GET /something HTTP/1.1
Cookie: X-API-KEY=abcdef12345
```

```typespec
model TypeSpec.Http.ApiKeyAuth<TLocation, TName>
```

#### Template Parameters

| Name      | Description                 |
| --------- | --------------------------- |
| TLocation | The location of the API key |
| TName     | The name of the API key     |

### `AuthorizationCodeFlow` {#TypeSpec.Http.AuthorizationCodeFlow}

Authorization Code flow

```typespec
model TypeSpec.Http.AuthorizationCodeFlow
```

### `BadRequestResponse` {#TypeSpec.Http.BadRequestResponse}

The server could not understand the request due to invalid syntax.

```typespec
model TypeSpec.Http.BadRequestResponse
```

### `BasicAuth` {#TypeSpec.Http.BasicAuth}

Basic authentication is a simple authentication scheme built into the HTTP protocol.
The client sends HTTP requests with the Authorization header that contains the word Basic word followed by a space and a base64-encoded string username:password.
For example, to authorize as demo / `p@55w0rd` the client would send

```
Authorization: Basic ZGVtbzpwQDU1dzByZA==
```

```typespec
model TypeSpec.Http.BasicAuth
```

### `BearerAuth` {#TypeSpec.Http.BearerAuth}

Bearer authentication (also called token authentication) is an HTTP authentication scheme that involves security tokens called bearer tokens.
The name “Bearer authentication” can be understood as “give access to the bearer of this token.” The bearer token is a cryptic string, usually generated by the server in response to a login request.
The client must send this token in the Authorization header when making requests to protected resources:

```
Authorization: Bearer <token>
```

```typespec
model TypeSpec.Http.BearerAuth
```

### `Body` {#TypeSpec.Http.Body}

Defines a model with a single property of the given type, marked with `@body`.

This can be useful in situations where you cannot use a bare T as the body
and it is awkward to add a property.

```typespec
model TypeSpec.Http.Body<T>
```

#### Template Parameters

| Name | Description                              |
| ---- | ---------------------------------------- |
| T    | The type of the model's `body` property. |

### `ClientCredentialsFlow` {#TypeSpec.Http.ClientCredentialsFlow}

Client credentials flow

```typespec
model TypeSpec.Http.ClientCredentialsFlow
```

### `ConflictResponse` {#TypeSpec.Http.ConflictResponse}

The request conflicts with the current state of the server.

```typespec
model TypeSpec.Http.ConflictResponse
```

### `CreatedResponse` {#TypeSpec.Http.CreatedResponse}

The request has succeeded and a new resource has been created as a result.

```typespec
model TypeSpec.Http.CreatedResponse
```

### `ForbiddenResponse` {#TypeSpec.Http.ForbiddenResponse}

Access is forbidden.

```typespec
model TypeSpec.Http.ForbiddenResponse
```

### `HeaderOptions` {#TypeSpec.Http.HeaderOptions}

Header options.

```typespec
model TypeSpec.Http.HeaderOptions
```

### `ImplicitFlow` {#TypeSpec.Http.ImplicitFlow}

Implicit flow

```typespec
model TypeSpec.Http.ImplicitFlow
```

### `LocationHeader` {#TypeSpec.Http.LocationHeader}

The Location header contains the URL where the status of the long running operation can be checked.

```typespec
model TypeSpec.Http.LocationHeader
```

### `MovedResponse` {#TypeSpec.Http.MovedResponse}

The URL of the requested resource has been changed permanently. The new URL is given in the response.

```typespec
model TypeSpec.Http.MovedResponse
```

### `NoContentResponse` {#TypeSpec.Http.NoContentResponse}

There is no content to send for this request, but the headers may be useful.

```typespec
model TypeSpec.Http.NoContentResponse
```

### `NotFoundResponse` {#TypeSpec.Http.NotFoundResponse}

The server cannot find the requested resource.

```typespec
model TypeSpec.Http.NotFoundResponse
```

### `NotModifiedResponse` {#TypeSpec.Http.NotModifiedResponse}

The client has made a conditional request and the resource has not been modified.

```typespec
model TypeSpec.Http.NotModifiedResponse
```

### `OAuth2Auth` {#TypeSpec.Http.OAuth2Auth}

OAuth 2.0 is an authorization protocol that gives an API client limited access to user data on a web server.
OAuth relies on authentication scenarios called flows, which allow the resource owner (user) to share the protected content from the resource server without sharing their credentials.
For that purpose, an OAuth 2.0 server issues access tokens that the client applications can use to access protected resources on behalf of the resource owner.
For more information about OAuth 2.0, see oauth.net and RFC 6749.

```typespec
model TypeSpec.Http.OAuth2Auth<TFlows>
```

#### Template Parameters

| Name   | Description                        |
| ------ | ---------------------------------- |
| TFlows | The list of supported OAuth2 flows |

### `OkResponse` {#TypeSpec.Http.OkResponse}

The request has succeeded.

```typespec
model TypeSpec.Http.OkResponse
```

### `PasswordFlow` {#TypeSpec.Http.PasswordFlow}

Resource Owner Password flow

```typespec
model TypeSpec.Http.PasswordFlow
```

### `PlainData` {#TypeSpec.Http.PlainData}

Produces a new model with the same properties as T, but with `@query`,
`@header`, `@body`, and `@path` decorators removed from all properties.

```typespec
model TypeSpec.Http.PlainData<T>
```

#### Template Parameters

| Name | Description                            |
| ---- | -------------------------------------- |
| T    | The model to spread as the plain data. |

### `QueryOptions` {#TypeSpec.Http.QueryOptions}

Query parameter options.

```typespec
model TypeSpec.Http.QueryOptions
```

### `Response` {#TypeSpec.Http.Response}

Describes an HTTP response.

```typespec
model TypeSpec.Http.Response<Status>
```

#### Template Parameters

| Name   | Description                      |
| ------ | -------------------------------- |
| Status | The status code of the response. |

### `UnauthorizedResponse` {#TypeSpec.Http.UnauthorizedResponse}

Access is unauthorized.

```typespec
model TypeSpec.Http.UnauthorizedResponse
```

### `ApiKeyLocation` {#TypeSpec.Http.ApiKeyLocation}

Describes the location of the API key

```typespec
enum TypeSpec.Http.ApiKeyLocation
```

### `AuthType` {#TypeSpec.Http.AuthType}

Authentication type

```typespec
enum TypeSpec.Http.AuthType
```

### `OAuth2FlowType` {#TypeSpec.Http.OAuth2FlowType}

Describes the OAuth2 flow type

```typespec
enum TypeSpec.Http.OAuth2FlowType
```
