> 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/he/authentication/is-authenticated.md).

# אימות עם מפתח הגישה

‫אין קריאת התחברות נפרדת. **מפתח ה-API (GUID)** של הארגון שלכם מועבר ישירות כפרמטר `token` בכל בקשה — כל מתודה מאמתת אותו באמצעות `IsAuthenticated`. התחברות עם אימייל וסיסמה (`VerifyLogin`) **הוצאה משימוש** — היא עדיין פועלת בתקופת המעבר, אך אינטגרציות חדשות חייבות להשתמש במפתח ה-API וקיימות צריכות לעבור אליו.‬

```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"
}
```

## ‫אימות מפתח: `IsAuthenticated`‬

‫מאמת מפתח API (או טוקן) ומחזיר את המשתמש שזוהה. שימושי לבדיקת פרטי גישה בשלב ההקמה.‬

|             |                                                   |
| ----------- | ------------------------------------------------- |
| ‫**מתודה**‬ | `POST`                                            |
| ‫**נתיב**‬  | `/IsAuthenticated`                                |
| ‫**גוף**‬   | `{ "token": "<API key>" }`                        |
| ‫**תשובה**‬ | ‫אובייקט `User`; בדקו את `Errors[]` לזיהוי בעיות‬ |

‫חשבון שפג תוקפו לפני יותר מ-**4 ימים** מקבל שגיאת `ExpiredAccount` על המשתמש המוחזר.‬

## ‫דוגמת בקשה‬

```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[]` מכיל `UnauthorizedUser` (80) | ‫מפתח לא נמצא, לא תקין או בוטל.‬     |
| `Errors[]` מכיל `ExpiredAccount` (66)   | ‫תוקף החשבון פג לפני יותר מ-4 ימים.‬ |

## ‫קשור: בדיקת תוקף החשבון‬

‫`GetExpDateByApiKey` מחזיר את תאריך תפוגת החשבון עבור המשתמש המאומת.‬

|             |                                               |
| ----------- | --------------------------------------------- |
| ‫**מתודה**‬ | `POST`                                        |
| ‫**נתיב**‬  | `/GetExpDateByApiKey`                         |
| ‫**גוף**‬   | `{ "token": "<API key>" }`                    |
| ‫**תשובה**‬ | ‫מחרוזת תאריך תפוגה, או `"UnauthorizedUser"`‬ |

## ‫נסו את זה‬

## 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"}}}}}}}}}}}
```
