> For the complete documentation index, see [llms.txt](https://invoice4u.gitbook.io/invoice4u-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://invoice4u.gitbook.io/invoice4u-docs/authentication/is-authenticated.md).

# Authenticate with Your API Key

There is no separate login call. Your organization **API key (GUID)** is passed directly as the `token` parameter in every request — each endpoint validates it via `IsAuthenticated`. Email+password login (`VerifyLogin`) is **deprecated** — it still works during the migration period, but new integrations must use the API key and existing ones should migrate to it.

```http
POST /Services/ApiService.svc/CreateDocument HTTP/1.1
Host: apiqa.invoice4u.co.il
Content-Type: application/json

{
  "doc": { ... },
  "token": "d2f1a6b3-1234-4c9a-9f00-1a2b3c4d5e6f"
}
```

## Verify a key: `IsAuthenticated`

Validates an API key (or token) and returns the resolved user. Useful for checking credentials during setup.

|              |                                              |
| ------------ | -------------------------------------------- |
| **Method**   | `POST`                                       |
| **Path**     | `/IsAuthenticated`                           |
| **Body**     | `{ "token": "<API key>" }`                   |
| **Response** | `User` object; check `Errors[]` for problems |

An account expired more than **4 days** ago adds an `ExpiredAccount` error to the returned user.

## Example request

```http
POST /Services/ApiService.svc/IsAuthenticated HTTP/1.1
Host: apiqa.invoice4u.co.il
Content-Type: application/json

{
  "token": "d2f1a6b3-1234-4c9a-9f00-1a2b3c4d5e6f"
}
```

## Errors

| Result                                      | Meaning                               |
| ------------------------------------------- | ------------------------------------- |
| `Errors[]` contains `UnauthorizedUser` (80) | Key not found, malformed, or revoked. |
| `Errors[]` contains `ExpiredAccount` (66)   | Account expired more than 4 days ago. |

## Related: check account expiry

`GetExpDateByApiKey` returns the account expiration date for the authenticated user.

|              |                                                 |
| ------------ | ----------------------------------------------- |
| **Method**   | `POST`                                          |
| **Path**     | `/GetExpDateByApiKey`                           |
| **Body**     | `{ "token": "<API key>" }`                      |
| **Response** | Expiration date string, or `"UnauthorizedUser"` |

## Try it

## Verify a token or API key

> Validates an organization API key (GUID) or token and returns the resolved user. An account expired more than 4 days ago adds an \`ExpiredAccount\` error.

```json
{"openapi":"3.0.3","info":{"title":"Invoice4U API","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Obtain and manage authentication tokens."}],"servers":[{"url":"https://api.invoice4u.co.il/Services/ApiService.svc","description":"Production"},{"url":"https://apiqa.invoice4u.co.il/Services/ApiService.svc","description":"QA (staging)"}],"paths":{"/IsAuthenticated":{"post":{"tags":["Authentication"],"operationId":"IsAuthenticated","summary":"Verify a token or API key","description":"Validates an organization API key (GUID) or token and returns the resolved user. An account expired more than 4 days ago adds an `ExpiredAccount` error.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["token"],"properties":{"token":{"type":"string","description":"Your organization API key (GUID)."}}}}}},"responses":{"200":{"description":"Resolved user, or a user object whose Errors array is populated when the token/key is invalid or the account is expired.","content":{"application/json":{"schema":{"type":"object","properties":{"IsAuthenticatedResult":{"type":"object","description":"Authenticated user details.","properties":{"ID":{"type":"integer"},"Email":{"type":"string"},"OrgID":{"type":"integer"},"ExpirationDate":{"type":"string","nullable":true},"Errors":{"type":"array","items":{"$ref":"#/components/schemas/CommonError"}}}}}}}}}}}}},"components":{"schemas":{"CommonError":{"type":"object","properties":{"ID":{"type":"integer","description":"Numeric error code, e.g. 80 = UnauthorizedUser, 134 = DocumentAlreadyCreated."},"Error":{"type":"string","description":"Error name."},"Paramters":{"type":"string","nullable":true,"description":"Optional context, e.g. \"Row Number - 0\"."}}}}}}
```

## POST /GetExpDateByApiKey

> Get account expiration date

```json
{"openapi":"3.0.3","info":{"title":"Invoice4U API","version":"1.0.0"},"tags":[{"name":"Authentication","description":"Obtain and manage authentication tokens."}],"servers":[{"url":"https://api.invoice4u.co.il/Services/ApiService.svc","description":"Production"},{"url":"https://apiqa.invoice4u.co.il/Services/ApiService.svc","description":"QA (staging)"}],"paths":{"/GetExpDateByApiKey":{"post":{"tags":["Authentication"],"operationId":"GetExpDateByApiKey","summary":"Get account expiration date","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["token"],"properties":{"token":{"type":"string"}}}}}},"responses":{"200":{"description":"Expiration date string or \"UnauthorizedUser\".","content":{"application/json":{"schema":{"type":"object","properties":{"GetExpDateByApiKeyResult":{"type":"string"}}}}}}}}}}}
```
