# Fetch one of your students, if they can use this organization

- Endpoint: `GET /v1/{organizationId}/student/{studentId}`
- Production: `https://api.main-team.org/v1/{organizationId}/student/{studentId}`
- Sandbox: `https://apisnd.main-team.org/v1/{organizationId}/student/{studentId}`
- Operation: `getOrgStudent` (Students)
- Authentication: `Authorization: Bearer <token>`, a short-lived token you sign with your API key and secret
- Permission: `student/read:$org:$ID`

## Description

Returns one student your account registered, if they can use this organization (their `activatedPlatformsThisSeason` holds its `slug` or `common`), with the references resolved as `listOrgStudents` returns them.

An unknown id, a student registered by another account and a student of yours without access to this organization all answer `404 not_found`, the same way. A malformed id is a 400.

To give a student access, use `updateOrgStudent`.

## Parameters

| Name | In | Required | Type | Description |
| --- | --- | --- | --- | --- |
| `organizationId` | path | yes | string | The organization’s `_id`: 24 hexadecimal digits, as `listOrganizations` (`GET /v1/organization`) lists it. |
| `studentId` | path | yes | string | The student’s id (`_id`), as `registerStudent` returned it. |

## Response

`200` Success: `message` is "Student fetched successfully".

```json
{
  "success": true,
  "message": "Student fetched successfully",
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 57,
    "totalPages": 3
  },
  "data": {
    "_id": "6650a1b2c3d4e5f6a7b8c9d0",
    "mainId": "6650a1b2c3d4e5f6a7b8c9d0",
    "username": "XXB1045",
    "firstName": "Jane",
    "lastName": "Doe",
    "fullName": "Jane Doe",
    "email": "jane.doe@example.com",
    "emailConfirmed": false,
    "phone": "+1 555 0100",
    "birth": "14/05/2008",
    "sex": "f",
    "country": {
      "_id": "6650a1b2c3d4e5f6a7b8c9d1",
      "name": "UNITED STATES",
      "iso3": "USA",
      "iso2": "US",
      "tz": "America/New_York",
      "dialCode": "+1",
      "flag": "🇺🇸",
      "createdAt": "2026-09-01T09:30:00.000Z",
      "updatedAt": "2026-09-02T14:05:00.000Z"
    },
    "city": {
      "_id": "6650a1b2c3d4e5f6a7b8c9d2",
      "name": "SPRINGFIELD",
      "country": "6650a1b2c3d4e5f6a7b8c9d1",
      "stateCode": "IL",
      "createdAt": "2026-09-01T09:30:00.000Z",
      "updatedAt": "2026-09-02T14:05:00.000Z"
    },
    "school": {
      "_id": "6650a1b2c3d4e5f6a7b8c9d3",
      "name": "SPRINGFIELD HIGH SCHOOL",
      "country": "6650a1b2c3d4e5f6a7b8c9d1",
      "city": "6650a1b2c3d4e5f6a7b8c9d2",
      "createdAt": "2026-09-01T09:30:00.000Z",
      "updatedAt": "2026-09-02T14:05:00.000Z"
    },
    "grade": {
      "_id": "6650a1b2c3d4e5f6a7b8c9d4",
      "name": "10",
      "createdAt": "2026-09-01T09:30:00.000Z",
      "updatedAt": "2026-09-02T14:05:00.000Z"
    },
    "supervisor": {
      "_id": "6650a1b2c3d4e5f6a7b8c9d5",
      "mainId": "6650a1b2c3d4e5f6a7b8c9d5",
      "firstName": "John",
      "lastName": "Smith",
      "fullName": "John Smith",
      "username": "XXT1003"
    },
    "partner": {
      "_id": "6650a1b2c3d4e5f6a7b8c9d5",
      "mainId": "6650a1b2c3d4e5f6a7b8c9d5",
      "firstName": "John",
      "lastName": "Smith",
      "fullName": "John Smith",
      "username": "XXT1003"
    },
    "activatedPlatformsThisSeason": [
      "common"
    ],
    "createdAt": "2026-09-01T09:30:00.000Z",
    "updatedAt": "2026-09-02T14:05:00.000Z"
  }
}
```

## Errors

| Status | Code | When |
| --- | --- | --- |
| 400 | [`bad_request`](https://hub.main-team.org/api/errors#bad_request) | `studentId` is not a well-formed id. |
| 401 | [`unauthorized`](https://hub.main-team.org/api/errors#unauthorized) | The token is missing or malformed, is not signed with your account’s `apiSecret`, breaks the `iat` and `exp` rules, has expired or been revoked, or its account is not active. All of these answer the same. |
| 403 | [`forbidden`](https://hub.main-team.org/api/errors#forbidden) | The token is valid, but no role on your account allows `student/read` on the organization in the path, or a role denies it. |
| 404 | [`not_found`](https://hub.main-team.org/api/errors#not_found) | `organizationId` is not the `_id` of an organization. |
| 404 | [`not_found`](https://hub.main-team.org/api/errors#not_found) | No student of yours with this id can use this organization: unknown, another account’s, or not activated here. |
| 429 | [`too_many_requests`](https://hub.main-team.org/api/errors#too_many_requests) | Your account has made more than 100 requests to this operation in the current 60-second window. Wait the seconds in `Retry-After` before sending again. |
| 500 | [`internal_error`](https://hub.main-team.org/api/errors#internal_error) | Something failed on our side. Retry later, and quote `request_id` if it goes on. |

## Code samples

### curl

```bash
# $TOKEN: a short-lived token you minted with your API key and secret
curl -sS 'https://api.main-team.org/v1/<organizationId>/student/<studentId>' \
  -H "Authorization: Bearer $TOKEN"
```

### Node.js

```js
const token = process.env.TOKEN; // a short-lived token you minted with your API key and secret

const res = await fetch('https://api.main-team.org/v1/<organizationId>/student/<studentId>', {
  headers: {
    Authorization: `Bearer ${token}`,
  },
});
const body = await res.json();
if (!res.ok) throw new Error(`${res.status} ${body.error.code}: ${body.error.message}`);
console.log(body.data);
```

### PHP

```php
<?php
$token = getenv('TOKEN'); // a short-lived token you minted with your API key and secret

$ch = curl_init('https://api.main-team.org/v1/<organizationId>/student/<studentId>');
curl_setopt_array($ch, [
    CURLOPT_HTTPHEADER => [
        'Authorization: Bearer ' . $token,
    ],
    CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
if ($response === false) {
    throw new RuntimeException(curl_error($ch));
}
$status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);
$body = json_decode($response, true);
if ($status >= 400) {
    $error = $body['error'];
    throw new RuntimeException("$status {$error['code']}: {$error['message']}");
}
print_r($body['data']);
```
