Stackfield API client for Node.js and the browser.
$ npm install stackfield-unofficialFollow the official documentation to add a Webhook integration of the appropriate type.
import * as stackfield from 'stackfield-unofficial';
const message: stackfield.ChatMessage = {
title: 'Hello, world!',
};
await stackfield.sendChatMessage({
webhookUrl: 'https://www.stackfield.com/apiwh/d4c7e4cf-2503-4d2c-99eb-7a5cf5f4b925',
message: message,
});<form id="myForm">
<input type="file" name="myFile" />
<button type="submit">Upload</button>
</form>
<script>
const form = document.querySelector('#myForm');
form.addEventListener('submit', async (e) => {
e.preventDefault();
const formData = new FormData(form);
const file = formData.get('myFile');
await stackfield.uploadFile({
webhookUrl: 'https://www.stackfield.com/apiwh/d4c7e4cf-2503-4d2c-99eb-7a5cf5f4b925',
file: { file: file, fileName: file.name },
});
});
</script>import { sendChatMessage, StackfieldError } from 'stackfield-unofficial';
try {
await sendChatMessage({
webhookUrl: 'https://www.stackfield.com/apiwh/d4c7e4cf-2503-4d2c-99eb-7a5cf5f4b925',
message: { title: 'Hello, world!' },
});
} catch (err) {
if (err instanceof StackfieldError) {
console.log(`Stackfield responded with error code: ${err.errorCode}`);
}
}import * as stackfield from 'stackfield-unofficial';
await stackfield.sendChatMessage(
{
webhookUrl: 'https://www.stackfield.com/apiwh/d4c7e4cf-2503-4d2c-99eb-7a5cf5f4b925',
message: {
title: 'Hello, world!',
},
},
{
fetch: (input, init) => {
const headers = new Headers(init?.headers);
headers.set('Custom-Header', 'value');
return fetch(input, { ...init, headers });
},
}
);sendChatMessagecreateDiscussioncreateTaskcreatePageuploadFilecreateEvent- endpoint has no official documentation and is therefore not supportedcreateSnippet
Enterprise features are not supported. We do not have access to the Enterprise features and therefore cannot reliably test them.