The Shulchan Aruch · Orach Chayim
אורח חיים ל״בOrach Chayim 32
Siman 32 of 697 in Orach Chayim — 52 se'ifim
הלכות תפיליןLaws of Tefillin· siman 32
Se’if 1א׳
מִצְוַת תְּפִלִּין שֶׁיִּכְתֹּב אַרְבַּע פָּרָשִׁיּוֹת שֶׁהֵן קַדֶּשׁ לִי כָּל בְּכוֹר עַד לְמוֹעֲדָהּ, וְהָיָה כִּי יְבִיאֲךָ עַד כִּי בְּחֹזֶק יָד הוֹצִיאָנוּ ה' מִמִּצְרָיִם, וּפָרָשַׁת שְׁמַע עַד וּבִשְׁעָרֶיךָ, וּפָרָשַׁת וְהָיָה אִם שָׁמוֹעַ עַד עַל הָאָרֶץ: הַגָּה: וְצָרִיךְ לְכָתְבָם בַּסֵּדֶר הַזֶּה לִכְתֹּב תְּחִלָּה הַקּוֹדֶמֶת בַּתּוֹרָה וְאִם שִׁנָּה פָּסוּל וּלְכַתְּחִלָּה יִכְתֹּב שֶׁל יָד קֹדֶם שֶׁל רֹאשׁ.
The commandment of "Tefillin" is to write four passages i.e. "Kadesh" until "l'moadah [m'yamim yamimah]"(Exodus 13:1-10); "v'haya ki yevi'acha" until "ki b'chozek yad hotziyanu Hashem mimitzrayim" (ibid 11-16); "Sh'ma" until "uvish'arekha" (Deuteronomy 6:4-9) and "v'haya im shamo'ah" until "al ha'aretz" (ibid 11:13-21) Rema: They must be written in this order, that is the order they appear in the Torah and if [the scribe] deviates from this order [the tefillin] are invalid. Ideally the arm-tefillin should be written before the head-tefillin.
Se’if 2ב׳
בְּשֶׁל רֹאשׁ יִכְתֹּב כָּל אַחַת בִּקְלָף לְבַדָּהּ, וְשֶׁל יָד כּוֹתֵב כֻּלָּם בִּקְלָף אֶחָד.
The head [tefillin] should be written each [parasha] on its own parchment and the arm [tefillin] should be written all [four] of them on a single piece of parchment.
Se’if 3ג׳
יִכְתְּבֵם בִּדְיוֹ שָׁחֹר בֵּין שֶׁיֵּשׁ בּוֹ מֵי עֲפָצִים בֵּין שֶׁלֹּא בְּמֵי עֲפָצִים: הַגָּה: וּלְכַתְּחִלָּה יַחְמִיר לִכְתֹּב בִּדְיוֹ הָעֲשׂוּיָה מֵעֲשַׁן עֵצִים אוֹ שְׁמָנִים שָׁרוּי בְּמֵי עֲפָצִים (מַהֲרִי"ל סי' קי"ט) וּכְמוֹ שֶׁיִּתְבָּאֵר בְּיוֹרֵה דֵּעָה סי' רע"א: כָּתַב אֲפִלּוּ אוֹת אַחַת בִּשְׁאָר מִינֵי צִבְעוֹנִים אוֹ בְּזָהָב, הֲרֵי אֵלּוּ פְּסוּלִין. אִם זָרַק עַפְרוֹת זָהָב עַל הָאוֹתִיּוֹת מַעֲבִיר הַזָּהָב וְיִשָּׁאֵר כְּתָב הַתַּחְתּוֹן, וְכָשֵׁר, אֲבָל אִם זָרַק הַזָּהָב עַל אוֹת מֵאַזְכָּרָה אֵין לוֹ תַּקָּנָה, לְפִי שֶׁאָסוּר לְהַעֲבִיר הַזָּהָב מִשּׁוּם דְּהָוֵי כְּמוֹחֵק אֶת הַשֵּׁם.
They should be written in black ink, whether or not the ink contains gallnut juice (tannic acid). Rema: It is preferable to be careful to write only with ink made of smoked wood or oil (ie. the collected vapors which were then dried and pulverized) soaked in gallnut juice [Maharil - Siman 119] and as is explained in Yoreh Deah - Siman 271.) If he wrote even one letter in a different color or in gold, the tefillin are invalid. If he gilded the letters, he can remove the gold and leave the bottom letters and the tefillin will be valid. But if he gilded [even] one letter of the Divine Names, there is no solution because removing the gold would constitute erasing a Divine Name [which is forbidden].
Shulchan Aruch, Orach Chayim — Torat Emet 363 edition, via Sefaria — public domain
English: Sefaria Community Translation — CC0