Edits history of script submission #14970 for ' Delete all source account credentials (codat)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Codat = {
    	encodedKey: string
    }
    /**
     * Delete all source account credentials
     * The _Delete Bank Account Credentials_ endpoint serves as a comprehensive mechanism for revoking all existing authorization credentials that a company employs to establish its Bank Feed connection.
    
    In cases where multiple credential sets have been generated, a single API call to this endpoint revokes all of them.
     */
    export async function main(auth: Codat, companyId: string, connectionId: string) {
    	const url = new URL(
    		`https://api.codat.io/companies/${companyId}/connections/${connectionId}/connectionInfo/bankFeedAccounts/credentials`
    	)
    
    	const response = await fetch(url, {
    		method: 'DELETE',
    		headers: {
    			Authorization: `Basic ${auth.encodedKey}`
    		},
    		body: undefined
    	})
    	if (!response.ok) {
    		const text = await response.text()
    		throw new Error(`${response.status} ${text}`)
    	}
    	return await response.text()
    }
    

    Submitted by hugo697 235 days ago