Manage Teachers
API integration guide for adding and removing teachers from an Andamio course
Manage Teachers
Course owners can add or remove teachers from an existing course. This transaction updates the on-chain teacher list and syncs the full list to the database, replacing the previous set entirely.
Summary
| Property | Value |
|---|---|
| System | Course |
| Role | Owner |
| Type Key | teachers_update |
| Build Endpoint | POST /api/v2/tx/course/owner/teachers/manage |
| DB Sync | Yes |
| Service Fee | 10 ADA |
| Est. Wallet Cost | ~10.3 ADA |
The estimated wallet cost breaks down as: transaction fee ~0.30 ADA + service fee 10 ADA. No additional UTxO deposits are required.
Build Transaction
Endpoint
POST /api/v2/tx/course/owner/teachers/manage
Request Body
{
"alias": "courseowner",
"courseId": "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
"teachersToAdd": ["newteacher1", "newteacher2"],
"teachersToRemove": ["oldteacher"],
"walletData": {
"usedAddresses": ["addr1qx2fxv..."],
"changeAddress": "addr1qx2fxv..."
}
}| Field | Type | Required | Description |
|---|---|---|---|
alias | string (Alias) | Yes | The course owner's access token alias. |
courseId | string (GYMintingPolicyId) | Yes | The 56-character hex policy ID returned when the course was created. |
teachersToAdd | string[] (Alias[]) | Yes | Aliases of teachers to add. Each must have a minted access token. Pass an empty array if not adding anyone. |
teachersToRemove | string[] (Alias[]) | Yes | Aliases of teachers to remove. Pass an empty array if not removing anyone. |
walletData | WalletData | No | Object containing usedAddresses (string[]) and changeAddress (string). |
Response
{
"unsignedTxCBOR": "84a800..."
}The response contains the unsigned transaction CBOR, ready for the user's wallet to sign.
Register Transaction
After the user signs and submits the transaction, register it with the state machine:
POST /api/v2/tx/register
{
"tx_hash": "64-char hex hash from wallet.submitTx()",
"tx_type": "teachers_update"
}No metadata is required. On confirmation, the state machine reads the full teacher list from the on-chain datum and replaces the entire teacher list in the database, ensuring the DB always mirrors the chain.
Related API Endpoints
| Endpoint | Description |
|---|---|
GET /api/v2/courses/{course_id} | Verify the updated teacher list after the transaction confirms |
Example: Full Lifecycle
const API_URL = "https://api.andamio.io";
// 1. Build
const buildRes = await fetch(`${API_URL}/api/v2/tx/course/owner/teachers/manage`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": API_KEY,
"Authorization": `Bearer ${userJwt}`,
},
body: JSON.stringify({
alias: "courseowner",
courseId: "a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4e5f6a1b2c3d4",
teachersToAdd: ["newteacher1", "newteacher2"],
teachersToRemove: [],
walletData: {
usedAddresses: [walletAddress],
changeAddress: walletAddress,
},
}),
});
const { unsignedTxCBOR } = await buildRes.json();
// 2. Sign
const signedTx = await wallet.signTx(unsignedTxCBOR);
// 3. Submit
const txHash = await wallet.submitTx(signedTx);
// 4. Register
await fetch(`${API_URL}/api/v2/tx/register`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": API_KEY,
"Authorization": `Bearer ${userJwt}`,
},
body: JSON.stringify({
tx_hash: txHash,
tx_type: "teachers_update",
}),
});
// 5. Monitor (SSE)
const events = new EventSource(
`${API_URL}/api/v2/tx/stream/${txHash}`
);
events.addEventListener("state_change", (e) => {
const data = JSON.parse(e.data);
console.log(`State: ${data.old_state} → ${data.new_state}`);
});
events.addEventListener("complete", (e) => {
const data = JSON.parse(e.data);
console.log(`Final: ${data.final_state}`);
events.close();
});See Also
- Transaction State Machine -- Lifecycle overview
- Cost Estimation -- Fee details
- On-Chain Structure -- CBOR anatomy
- Teacher: Manage Modules -- Next step: teachers add learning modules