Code Examples & SDKs
Production code examples for integrating Cortex ASO APIs across TypeScript, Python, cURL, Next.js, and Flutter.
Code Examples & SDKs
Here are battle-tested code snippets demonstrating common tasks across various environments.
1. User Authentication & Login
interface LoginResponse {
accessToken: string
refreshToken: string
sessionId: string
}
async function login(email: string, password: string): Promise<LoginResponse> {
const res = await fetch('https://api.cortexaso.com/api/user/auth/v1/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password }),
})
if (!res.ok) {
throw new Error(`Login failed with HTTP ${res.status}`)
}
return res.json()
}2. Searching Applications During Onboarding
// Query iOS and Android store listings
async function searchApps(query: string, storefront = 'US') {
const token = process.env.CORTEX_ACCESS_TOKEN
const res = await fetch(
`https://api.cortexaso.com/api/app_onboarding/v1/apps/search?q=${encodeURIComponent(query)}&storefront=${storefront}`,
{
headers: {
Authorization: `Bearer ${token}`,
},
}
)
return res.json()
}3. Creating Support Tickets with Attachments
async function createSupportTicket(title: string, issueDetail: string) {
const token = process.env.CORTEX_ACCESS_TOKEN
const res = await fetch('https://api.cortexaso.com/api/user/support/v1/tickets', {
method: 'POST',
headers: {
Authorization: `Bearer ${token}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
title,
issueDetail,
attachments: [],
}),
})
return res.json()
}