Edits history of script submission #12705 for ' Revoke an organization API key (neondb)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Neondb = {
    	apiKey: string
    }
    /**
     * Revoke an organization API key
     * Revokes the specified organization API key.
    An API key that is no longer needed can be revoked.
    This action cannot be reversed.
    You can obtain `key_id` values by listing the API keys for an organization.
    API keys can also be managed in the Neon Console.
    See [Manage API keys](https://neon.tech/docs/manage/api-keys/).
    
     */
    export async function main(auth: Neondb, org_id: string, key_id: string) {
    	const url = new URL(`https://console.neon.tech/api/v2/organizations/${org_id}/api_keys/${key_id}`)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: 'Bearer ' + auth.apiKey
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.json()
    }
    

    Submitted by hugo697 428 days ago