Skip to main content

Check if User Account Exists

Fetching Nav user account information is done through GraphQL query. See Using our GraphQL API and account GraphQL Query.

Used to determine if a Nav user account exists and get basic account information.

Required arguments:

  • userID

User ID

The userID argument is a unique identifier created by you to link your user to our data. It is a required argument for almost all our queries and mutations. It can be any string, up to 255 characters long.

Example

import fetch from 'node-fetch'

const doesAccountExist = async (userID) => {
// Use GraphQL to request an Authentication Code
const response = await fetch('https://api.nav.com/partners/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'my-secret-api-key',
'x-partner-id': 'my-partner-id',
},
body: JSON.stringify({
query: `
query CheckAccountExists($userID: String!) {
account(userID: $userID) {
userID
}
}
`,
variables: {
userID: userID
}
})
})
const responseData = await response.json()

return !!responseData.data.account
}