Pterodactyl PHP SDK
  • Documentation
  • Basics
    • Installation
    • SDK initialization
  • API - Application
    • Users
    • Nodes
    • Nodes -> Allocations
    • Locations
    • Servers
    • Servers -> Databases
    • Nests
  • API - Client
    • Basic functions
    • Account
    • Server
    • Server -> Databases
    • Server -> File Manager
    • Server -> Schedules
    • Server -> Network (allocations)
    • Server -> Users
    • Server -> Backups
    • Server -> Startup
    • Server -> Settings
Powered by GitBook
On this page
  • Get users
  • Find user
  • Create new user
  • Update user
  • Delete user
  1. API - Application

Users

$client->application->users

Get users

$client->application->users->paginate(int $page = 1);

Example response:

{
    "object": "list",
    "data": [
        {
            "object": "user",
            "attributes": {
                "id": 1,
                "external_id": null,
                "uuid": "6484c516-752a-44c3-9776-5359b0c0b394",
                "username": "patryqhyper",
                "email": "vizauerp@gmail.com",
                "first_name": "Patryk",
                "last_name": "Vizauer",
                "language": "en",
                "root_admin": true,
                "2fa": false,
                "created_at": "2021-12-17T23:49:47+00:00",
                "updated_at": "2021-12-17T23:49:47+00:00"
            }
        }
    ],
    "meta": {
        "pagination": {
            "total": 3,
            "count": 3,
            "per_page": 50,
            "current_page": 1,
            "total_pages": 1,
            "links": {}
        }
    }
}

Find user

$client->application->users->find(int $userId);

You may also find user using external_id:

$client->application->users->findByExternal('externalId');

Example response:

{
    "object": "user",
    "attributes": {
        "id": 4,
        "external_id": null,
        "uuid": "ae3277bb-29c3-43c4-8e24-2c5300862fb4",
        "username": "test",
        "email": "test@wp.pl",
        "first_name": "sdk",
        "last_name": "php",
        "language": "en",
        "root_admin": false,
        "2fa": false,
        "created_at": "2021-12-18T15:12:06+00:00",
        "updated_at": "2021-12-18T15:12:06+00:00"
    }
}

Create new user

$client->application->users->create([
    'email' => 'email@email.pl',
    'username' => 'username',
    'first_name' => 'sdk',
    'last_name' => 'php'
]))

Example response:

{
    "object": "user",
    "attributes": {
        "id": 4,
        "external_id": null,
        "uuid": "ae3277bb-29c3-43c4-8e24-2c5300862fb4",
        "username": "test",
        "email": "test@wp.pl",
        "first_name": "sdk",
        "last_name": "php",
        "language": "en",
        "root_admin": false,
        "2fa": false,
        "created_at": "2021-12-18T15:12:06+00:00",
        "updated_at": "2021-12-18T15:12:06+00:00"
    },
    "meta": {
        "resource": "http:\/\/newptero.hyperapp.ovh\/api\/application\/users\/4"
    }
}

Update user

$client->application->users->update(int $userId, array $data = [])

Example response:

{
    "object": "user",
    "attributes": {
        "id": 4,
        "external_id": null,
        "uuid": "ae3277bb-29c3-43c4-8e24-2c5300862fb4",
        "username": "test",
        "email": "test@wp.pl",
        "first_name": "test",
        "last_name": "t",
        "language": "en",
        "root_admin": false,
        "2fa": false,
        "created_at": "2021-12-18T15:12:06+00:00",
        "updated_at": "2021-12-18T16:41:44+00:00"
    }
}

Delete user

$client->application->users->delete(int $userId);

Example response:

true // requests, which return http code 204, return true on success.
PreviousSDK initializationNextNodes

Last updated 3 years ago