# List user's workspaces

GET //localhost:8080/api/v1/workspaces

Returns all workspaces the authenticated user belongs to. Paginated (page, pageSize; max pageSize 100).

Reference: https://api.alephant.io/api-reference/saa-s-api/workspaces/list-users-workspaces

## OpenAPI Specification

```yaml
openapi: 3.1.0
info:
  title: saas-openapi
  version: 1.0.0
paths:
  /api/v1/workspaces:
    get:
      operationId: list-users-workspaces
      summary: List user's workspaces
      description: >-
        Returns all workspaces the authenticated user belongs to. Paginated
        (page, pageSize; max pageSize 100).
      tags:
        - subpackage_workspaces
      parameters:
        - name: page
          in: query
          description: Page number
          required: false
          schema:
            type: integer
            default: 1
        - name: pageSize
          in: query
          description: Items per page
          required: false
          schema:
            type: integer
            default: 20
        - name: Authorization
          in: header
          description: Bearer {access_token}
          required: true
          schema:
            type: string
      responses:
        '200':
          description: 'data: list, meta: pagination'
          content:
            application/json:
              schema:
                $ref: >-
                  #/components/schemas/internal_api_handlers_workspaces.ListWorkspacesResponse
        '401':
          description: AUTH_TOKEN_EXPIRED
          content:
            application/json:
              schema:
                type: object
                additionalProperties:
                  description: Any type
servers:
  - url: //localhost:8080
components:
  schemas:
    internal_api_handlers_workspaces.WorkspaceListItemDTO:
      type: object
      properties:
        createdAt:
          type: string
        id:
          type: string
        logoUrl:
          type: string
        name:
          type: string
        role:
          type: string
        slug:
          type: string
        tier:
          type: string
        type:
          type: string
      title: internal_api_handlers_workspaces.WorkspaceListItemDTO
    internal_api_handlers_workspaces.Meta:
      type: object
      properties:
        page:
          type: integer
        pageSize:
          type: integer
        total:
          type: integer
        totalPages:
          type: integer
      title: internal_api_handlers_workspaces.Meta
    internal_api_handlers_workspaces.ListWorkspacesResponse:
      type: object
      properties:
        data:
          type: array
          items:
            $ref: >-
              #/components/schemas/internal_api_handlers_workspaces.WorkspaceListItemDTO
        meta:
          $ref: '#/components/schemas/internal_api_handlers_workspaces.Meta'
      title: internal_api_handlers_workspaces.ListWorkspacesResponse

```

## SDK Code Examples

```python
import requests

url = "https://localhost:8080/api/v1/workspaces"

payload = {}
headers = {
    "Authorization": "Authorization",
    "Content-Type": "application/json"
}

response = requests.get(url, json=payload, headers=headers)

print(response.json())
```

```javascript
const url = 'https://localhost:8080/api/v1/workspaces';
const options = {
  method: 'GET',
  headers: {Authorization: 'Authorization', 'Content-Type': 'application/json'},
  body: '{}'
};

try {
  const response = await fetch(url, options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

```go
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://localhost:8080/api/v1/workspaces"

	payload := strings.NewReader("{}")

	req, _ := http.NewRequest("GET", url, payload)

	req.Header.Add("Authorization", "Authorization")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(res)
	fmt.Println(string(body))

}
```

```ruby
require 'uri'
require 'net/http'

url = URI("https://localhost:8080/api/v1/workspaces")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Authorization'
request["Content-Type"] = 'application/json'
request.body = "{}"

response = http.request(request)
puts response.read_body
```

```java
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;

HttpResponse<String> response = Unirest.get("https://localhost:8080/api/v1/workspaces")
  .header("Authorization", "Authorization")
  .header("Content-Type", "application/json")
  .body("{}")
  .asString();
```

```php
<?php
require_once('vendor/autoload.php');

$client = new \GuzzleHttp\Client();

$response = $client->request('GET', 'https://localhost:8080/api/v1/workspaces', [
  'body' => '{}',
  'headers' => [
    'Authorization' => 'Authorization',
    'Content-Type' => 'application/json',
  ],
]);

echo $response->getBody();
```

```csharp
using RestSharp;

var client = new RestClient("https://localhost:8080/api/v1/workspaces");
var request = new RestRequest(Method.GET);
request.AddHeader("Authorization", "Authorization");
request.AddHeader("Content-Type", "application/json");
request.AddParameter("application/json", "{}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
```

```swift
import Foundation

let headers = [
  "Authorization": "Authorization",
  "Content-Type": "application/json"
]
let parameters = [] as [String : Any]

let postData = JSONSerialization.data(withJSONObject: parameters, options: [])

let request = NSMutableURLRequest(url: NSURL(string: "https://localhost:8080/api/v1/workspaces")! as URL,
                                        cachePolicy: .useProtocolCachePolicy,
                                    timeoutInterval: 10.0)
request.httpMethod = "GET"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data

let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
  if (error != nil) {
    print(error as Any)
  } else {
    let httpResponse = response as? HTTPURLResponse
    print(httpResponse)
  }
})

dataTask.resume()
```