You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**This SDK is compatible with Appwrite server version 1.4.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).**
9
+
**This SDK is compatible with Appwrite server version 1.5.x. For older versions, please check [previous releases](https://github.com/appwrite/sdk-for-php/releases).**
10
10
11
11
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the PHP SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to [https://appwrite.io/docs](https://appwrite.io/docs)
Copy file name to clipboardExpand all lines: docs/account.md
+246-6Lines changed: 246 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -8,6 +8,23 @@ GET https://HOSTNAME/v1/account
8
8
9
9
** Get the currently logged in user. **
10
10
11
+
## Create account
12
+
13
+
```http request
14
+
POST https://HOSTNAME/v1/account
15
+
```
16
+
17
+
** Use this endpoint to allow a new user to register a new account in your project. After the user registration completes successfully, you can use the [/account/verfication](https://appwrite.io/docs/references/cloud/client-web/account#createVerification) route to start verifying the user email address. To allow the new user to login to their new account, you need to create a new [account session](https://appwrite.io/docs/references/cloud/client-web/account#createEmailSession). **
18
+
19
+
### Parameters
20
+
21
+
| Field Name | Type | Description | Default |
22
+
| --- | --- | --- | --- |
23
+
| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. ||
24
+
| email | string | User email. ||
25
+
| password | string | New user password. Must be between 8 and 256 chars. ||
26
+
| name | string | User name. Max length: 128 chars. ||
27
+
11
28
## Update email
12
29
13
30
```http request
@@ -37,9 +54,9 @@ GET https://HOSTNAME/v1/account/identities
37
54
38
55
| Field Name | Type | Description | Default |
39
56
| --- | --- | --- | --- |
40
-
| queries |string| Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry |[]|
57
+
| queries |array| Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Maximum of 100 queries are allowed, each 4096 characters long. You may filter on the following attributes: userId, provider, providerUid, providerEmail, providerAccessTokenExpiry |[]|
** Use this endpoint to create a JSON Web Token. You can use the resulting JWT to authenticate on behalf of the current user when working with the Appwrite server-side API and SDKs. The JWT secret is valid for 15 minutes from its creation and will be invalid if the user will logout in that time frame. **
80
+
56
81
## List logs
57
82
58
83
```http request
@@ -67,6 +92,89 @@ GET https://HOSTNAME/v1/account/logs
67
92
| --- | --- | --- | --- |
68
93
| queries | array | Array of query strings generated using the Query class provided by the SDK. [Learn more about queries](https://appwrite.io/docs/queries). Only supported methods are limit and offset |[]|
** Delete all sessions from the user account and remove any sessions cookies from the end client. **
185
292
293
+
## Create anonymous session
294
+
295
+
```http request
296
+
POST https://HOSTNAME/v1/account/sessions/anonymous
297
+
```
298
+
299
+
** Use this endpoint to allow a new user to register an anonymous account in your project. This route will also create a new session for the user. To allow the new user to convert an anonymous account to a normal account, you need to update its [email and password](https://appwrite.io/docs/references/cloud/client-web/account#updateEmail) or create an [OAuth2 session](https://appwrite.io/docs/references/cloud/client-web/account#CreateOAuth2Session). **
300
+
301
+
## Create email password session
302
+
303
+
```http request
304
+
POST https://HOSTNAME/v1/account/sessions/email
305
+
```
306
+
307
+
** Allow the user to login into their account by providing a valid email and password combination. This route will create a new session for the user.
308
+
309
+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). **
310
+
311
+
### Parameters
312
+
313
+
| Field Name | Type | Description | Default |
314
+
| --- | --- | --- | --- |
315
+
| email | string | User email. ||
316
+
| password | string | User password. Must be at least 8 chars. ||
317
+
318
+
## Create session (deprecated)
319
+
320
+
```http request
321
+
PUT https://HOSTNAME/v1/account/sessions/magic-url
322
+
```
323
+
324
+
** Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. **
325
+
326
+
### Parameters
327
+
328
+
| Field Name | Type | Description | Default |
329
+
| --- | --- | --- | --- |
330
+
| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. ||
331
+
| secret | string | Valid verification token. ||
332
+
333
+
## Create OAuth2 session
334
+
335
+
```http request
336
+
GET https://HOSTNAME/v1/account/sessions/oauth2/{provider}
337
+
```
338
+
339
+
** Allow the user to login to their account using the OAuth2 provider of their choice. Each OAuth2 provider should be enabled from the Appwrite console first. Use the success and failure arguments to provide a redirect URL's back to your app when login is completed.
340
+
341
+
If there is already an active session, the new session will be attached to the logged-in account. If there are no active sessions, the server will attempt to look for a user with the same email address as the email received from the OAuth2 provider and attach the new session to the existing user. If no matching user is found - the server will create a new user.
342
+
343
+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
| success | string | URL to redirect back to your app after a successful login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. ||
352
+
| failure | string | URL to redirect back to your app after a failed login attempt. Only URLs from hostnames in your project's platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. ||
353
+
| token | boolean | Include token credentials in the final redirect, useful for server-side integrations, or when cookies are not available. ||
354
+
| scopes | array | A list of custom OAuth2 scopes. Check each provider internal docs for a list of supported scopes. Maximum of 100 scopes are allowed, each 4096 characters long. |[]|
355
+
356
+
## Create session
357
+
358
+
```http request
359
+
POST https://HOSTNAME/v1/account/sessions/token
360
+
```
361
+
362
+
** Use this endpoint to create a session from token. Provide the **userId** and **secret** parameters from the successful response of authentication flows initiated by token creation. For example, magic URL and phone login. **
363
+
364
+
### Parameters
365
+
366
+
| Field Name | Type | Description | Default |
367
+
| --- | --- | --- | --- |
368
+
| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. ||
369
+
| secret | string | Secret of a token generated by login methods. For example, the `createMagicURLToken` or `createPhoneToken` methods. ||
370
+
186
371
## Get session
187
372
188
373
```http request
@@ -197,13 +382,13 @@ GET https://HOSTNAME/v1/account/sessions/{sessionId}
197
382
| --- | --- | --- | --- |
198
383
| sessionId | string |**Required** Session ID. Use the string 'current' to get the current device session. ||
**Access tokens have limited lifespan and expire to mitigate security risks. If session was created using an OAuth provider, this route can be used to "refresh" the access token. **
391
+
**Extend session's expiry to increase it's lifespan. Extending a session is useful when session length is short such as 5 minutes. **
** Block the currently logged in user account. Behind the scene, the user record is not deleted but permanently blocked from any access. To completely delete a user, use the Users API instead. **
235
420
421
+
## Create email token (OTP)
422
+
423
+
```http request
424
+
POST https://HOSTNAME/v1/account/tokens/email
425
+
```
426
+
427
+
** Sends the user an email with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's email is valid for 15 minutes.
428
+
429
+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). **
430
+
431
+
### Parameters
432
+
433
+
| Field Name | Type | Description | Default |
434
+
| --- | --- | --- | --- |
435
+
| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. ||
436
+
| email | string | User email. ||
437
+
| phrase | boolean | Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. ||
438
+
439
+
## Create magic URL token
440
+
441
+
```http request
442
+
POST https://HOSTNAME/v1/account/tokens/magic-url
443
+
```
444
+
445
+
** Sends the user an email with a secret key for creating a session. If the provided user ID has not been registered, a new user will be created. When the user clicks the link in the email, the user is redirected back to the URL you provided with the secret key and userId values attached to the URL query string. Use the query string parameters to submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The link sent to the user's email address is valid for 1 hour. If you are on a mobile device you can leave the URL parameter empty, so that the login completion will be handled by your Appwrite instance by default.
446
+
447
+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits).
448
+
**
449
+
450
+
### Parameters
451
+
452
+
| Field Name | Type | Description | Default |
453
+
| --- | --- | --- | --- |
454
+
| userId | string | User ID. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. ||
455
+
| email | string | User email. ||
456
+
| url | string | URL to redirect the user back to your app from the magic URL login. Only URLs from hostnames in your project platform list are allowed. This requirement helps to prevent an [open redirect](https://cheatsheetseries.owasp.org/cheatsheets/Unvalidated_Redirects_and_Forwards_Cheat_Sheet.html) attack against your project API. ||
457
+
| phrase | boolean | Toggle for security phrase. If enabled, email will be send with a randomly generated phrase and the phrase will also be included in the response. Confirming phrases match increases the security of your authentication flow. ||
458
+
459
+
## Create phone token
460
+
461
+
```http request
462
+
POST https://HOSTNAME/v1/account/tokens/phone
463
+
```
464
+
465
+
** Sends the user an SMS with a secret key for creating a session. If the provided user ID has not be registered, a new user will be created. Use the returned user ID and secret and submit a request to the [POST /v1/account/sessions/token](https://appwrite.io/docs/references/cloud/client-web/account#createSession) endpoint to complete the login process. The secret sent to the user's phone is valid for 15 minutes.
466
+
467
+
A user is limited to 10 active sessions at a time by default. [Learn more about session limits](https://appwrite.io/docs/authentication-security#limits). **
468
+
469
+
### Parameters
470
+
471
+
| Field Name | Type | Description | Default |
472
+
| --- | --- | --- | --- |
473
+
| userId | string | Unique Id. Choose a custom ID or generate a random ID with `ID.unique()`. Valid chars are a-z, A-Z, 0-9, period, hyphen, and underscore. Can't start with a special char. Max length is 36 chars. ||
474
+
| phone | string | Phone number. Format this number with a leading '+' and a country code, e.g., +16175551212. ||
0 commit comments